Sure. You will need to write the file to disk using something like:
If your data are in an array called arrayName and you can replace saveFileName with a literal string of the file to save. Make sure it has the extension of ".img".
You might have to play with flipping the data around to have it look right in spm.
% scale to fit in 2byte word.
arrayName = arrayName/max(max(max(arrayName)))*32000;
fid = fopen(saveFileName,'w');
count = fwrite(fid,arrayName,'short');
close(fid);
that piece of code will write it to a format that is basically analyze. Then you can start up spm and hit the "hdr edit" button which in the lower 3rd of the main spm control panel. Under options you will need to do the following in this basic order (crucial to do 4) and 5) as the last two steps respectively.)
1) set image dimensions - pixels x, y, z
the answer to this is the image size your m*n*nslices. You'll be typing in 3 numbers seperated by spaces.
2) set voxel dimensions - mm in x, y, z
the answer to this is the size of the voxel (fov/matrix and slice thickness) (you'll be typing in 3 numbers seperated by spaces)
3) set origin
the answer to this can be the answer to 1 but divided by 2.
4) apply to images. To this you will point to the file written above.
5) quit the hdr edit.
Finally, check by trying to display the image.
Hope this helps.
Robert Welsh
>>> chang sheng wang <[log in to unmask]> 08/06/01 06:03PM >>>
hello, Dr. Welsh:
thanks for your response. as you saying, i want to use it as image file.
but i have no idea how to transform it to analyze format. spm_vol and
spm_write_vol all require the file have header file and a struct which
includes fname, dim, mat, pinfo,and description. am i right? but i have no
these informations. could i transform it to analyze form? would you please
help me about it? many thanks.
with best regards,
changsheng wang
On Mon, 6 Aug 2001, Robert Welsh wrote:
> Do you mean to use is as an image file? If so you will need to get it into the ANALYZE format. Do a
>
> help spm_write_vol and
> help spm_vol
>
> to get information about where to start looking.
>
> If not as image file, I am not quite sure what you want to do with it in spm. Maybe a little more explanation would help.
>
> Robert Welsh
>
>
> -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> Robert C. Welsh, PhD
> Research Investigator
> Department of Radiology
> University of Michigan
> (734) - 764 - 2412 (fax)
> [log in to unmask]
>
>
>
> >>> Changsheng Wang < [log in to unmask]> 08/06/01 05:35PM >>>
> hello, SPM users,
> I have one mat file which is m*n double arrays and could be load by matlab
> and shown, how can I use it with SPM without header file and its 4*4 affine
> matrix? I am very appreciate your kind help.
>
> Changsheng Wang
>
> ===============================================
> Changsheng Wang, M.D., Ph.D.,
> Clinical& Magnetic Resonance Research Center,
> University of New Mexico,
> Albuquerque, NM 87107
> email: [log in to unmask]
> ===============================================
>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
<BODY style="MARGIN-TOP: 2px; FONT: 10pt Tahoma; MARGIN-LEFT: 2px">
<DIV>Sure. You will need to write the file to disk using something like:</DIV>
<DIV> </DIV>
<DIV>If your data are in an array called arrayName and you can replace
saveFileName with a literal string of the file to save. Make sure it has the
extension of ".img".</DIV>
<DIV> </DIV>
<DIV>You might have to play with flipping the data around to have it look right
in spm. </DIV>
<DIV> </DIV>
<DIV>% scale to fit in 2byte word.</DIV>
<DIV>arrayName = arrayName/max(max(max(arrayName)))*32000;</DIV>
<DIV>fid = fopen(saveFileName,'w');</DIV>
<DIV>count = fwrite(fid,arrayName,'short');</DIV>
<DIV>close(fid);</DIV>
<DIV> </DIV>
<DIV>that piece of code will write it to a format that is basically analyze.
Then you can start up spm and hit the "hdr edit" button which in the lower 3rd
of the main spm control panel. Under options you will need to do the following
in this basic order (crucial to do 4) and 5) as the last two steps
respectively.)</DIV>
<DIV> </DIV>
<DIV>1) set image dimensions - pixels x, y, z<BR> the answer to this is the
image size your m*n*nslices. You'll be typing in 3 numbers seperated by
spaces.</DIV>
<DIV>2) set voxel dimensions - mm in x, y, z</DIV>
<DIV> the answer to this is the size of the voxel (fov/matrix and slice
thickness) (you'll be typing in 3 numbers seperated by spaces)</DIV>
<DIV>3) set origin</DIV>
<DIV> the answer to this can be the answer to 1 but divided by 2.</DIV>
<DIV>4) apply to images. To this you will point to the file written above.
</DIV>
<DIV>5) quit the hdr edit. </DIV>
<DIV> </DIV>
<DIV>Finally, check by trying to display the image.</DIV>
<DIV> </DIV>
<DIV>Hope this helps.</DIV>
<DIV> </DIV>
<DIV>Robert Welsh</DIV>
<DIV><BR>>>> chang sheng wang <[log in to unmask]> 08/06/01 06:03PM
>>> <BR>hello, Dr. Welsh: <BR>thanks for your response. as you saying,
i want to use it as image file. <BR>but i have no idea how to transform it to
analyze format. spm_vol and <BR>spm_write_vol all require the file have header
file and a struct which <BR>includes fname, dim, mat, pinfo,and description. am
i right? but i have no <BR>these informations. could i transform it to analyze
form? would you please <BR>help me about it? many thanks. <BR><BR>with best
regards, <BR>changsheng wang <BR><BR>On Mon, 6 Aug 2001, Robert Welsh wrote:
<BR><BR>> Do you mean to use is as an image file? If so you will need to get
it into the ANALYZE format. Do a <BR>> <BR>> help spm_write_vol and
<BR>> help spm_vol <BR>> <BR>> to get information about where to start
looking. <BR>> <BR>> If not as image file, I am not quite sure what you
want to do with it in spm. Maybe a little more explanation would help. <BR>>
<BR>> Robert Welsh <BR>> <BR>> <BR>>
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <BR>> Robert C. Welsh, PhD <BR>> Research
Investigator <BR>> Department of Radiology <BR>> University of Michigan
<BR>> (734) - 764 - 2412 (fax) <BR>> <U><A
href="mailto:[log in to unmask]">[log in to unmask]</A> <BR>> <BR>> <BR>>
<BR>> >>> Changsheng Wang <<U> <A
href="mailto:[log in to unmask]">[log in to unmask]</A>> 08/06/01 05:35PM
>>> <BR>> hello, SPM users, <BR>> I have one mat file which is
m*n double arrays and could be load by matlab <BR>> and shown, how can I use
it with SPM without header file and its 4*4 affine <BR>> matrix? I am very
appreciate your kind <A href="http://help.">help. </A><BR>> <BR>>
Changsheng Wang <BR>> <BR>>
=============================================== <BR>> Changsheng Wang, <A
href="http://M.D.,">M.D.,</A> <A href="http://Ph.D.,">Ph.D., </A><BR>>
Clinical& Magnetic Resonance Research Center, <BR>> University of New
Mexico, <BR>> Albuquerque, NM 87107 <BR>> email: <U><A
href="mailto:[log in to unmask]">[log in to unmask]</A> <BR>>
=============================================== <BR>>
<BR><BR></DIV></U></U></U></BODY></HTML>
|