Hi Ping,
check out the description given in spm_vol.m to get an overview of the
information that can be included in the structure V of Marko's example:
V.dt would define the data type. So, just change the lines like this:
P = spm_select(1,'IMAGE','Select an image, please',[],pwd);
V = spm_vol(P);
noise = rand(V.dim(1:3));
[p nm e v] = fileparts(V.fname);
V.fname = [p filesep 'random_noise_64bit.img'];
V.descrip = 'random noise image';
V.dt = [64 0];
spm_write_vol(V, noise);
to set the data type to 'float64' (see spm_type.m for a list of possible
data types).
Hope this works ;-)
Cheers,
Kai
Wang Ping schrieb:
> Hello Marko,
>
> It works pretty well, thanks. But I still have a question, where to
> setup the data type(for example if I want to designate the data to
> double, float, etc)
> Seems V in your email below doesn't include the data type information.
>
> Thanks, ping
>
>> From: Marko Wilke <[log in to unmask]>
>> To: Wang Ping <[log in to unmask]>
>> CC: [log in to unmask]
>> Subject: Re: [SPM] functions to write analyze file
>> Date: Mon, 30 Jul 2007 20:46:16 +0200
>>
>> Hello,
>>
>> if you take a look at the code of spm_write_vol, that should get you
>> going. The necessary structure can easily be obtained using spm_vol and
>> can then be modified to your needs, as in
>>
>> V = spm_select(1,'IMAGE','Select an image, please',[],pwd);
>> V = spm_vol(V);
>> noise = rand(V.dim(1:3));
>> [p nm e v] = fileparts(V.fname);
>> V.fname = [p filesep 'random_noise.img'];
>> V.descrip = 'random noise image';
>> spm_write_vol(V, noise);
>>
>> Voila :)
>> Best,
>> Marko
>>
>>
>> Wang Ping schrieb:
>>
>>> Dear SPM experts:
>>>
>>> I just downloaded SPM5, I am wondering is there any functions that
>>> can write an analyze format file (say, *.hdr, and *.img).
>>>
>>> Thanks,
>>> Ping Wang
>>>
>>> _________________________________________________________________
>>> 免费下载 MSN Explorer: http://explorer.msn.com/lccn
>>>
>>
>> --
>> =====================================================================
>> Marko Wilke (Dr.med./M.D.)
>> [log in to unmask]
>>
>> Universitäts-Kinderklinik University Children's Hospital
>> Abt. III (Neuropädiatrie) Dept. III (Pediatric neurology)
>> Hoppe-Seyler-Str. 1, D - 72076 Tübingen
>> Tel.: (+49) 07071 29-83416 Fax: (+49) 07071 29-5473
>> =====================================================================
>
>
> _________________________________________________________________
> ĵʼϵͳ MSN Hotmail http://www.hotmail.com
|