Print

Print


Dear Mark, dear Ged,

thank you very much for your help.

The data I'm using is provided by the faculty of medicine. As it turned 
out they are indeed using SPM2 and I could therefor make good use of the 
matlab scripts.

Kindest regards,

Stefan



Ged Ridgway wrote:
> Mark Jenkinson wrote:
>> The problem is that your .mat file is not a text matrix that FLIRT would
>> have written.  It is some binary format file.
>
>>>>> I'm using the FSL package to build a voxel-model for 
>>>>> bio-electromagnetic
>>>>> simulations in the human head. The data is provided in the NIfTI 
>>>>> format
>>>>> as a .hdr/.img pair. The 4x4 affine transformation matrix is also 
>>>>> saved
>>>>> as a .mat file.
>
> At a wild guess, I would say this is an Analyze (not NIfTI) hdr/img 
> pair and a MATLAB .mat containing the affine transformation from SPM2.
>
> If you have access to MATLAB, try "load blah.mat" and see if it either 
> complains or gives you a 4x4 affine matrix called mat (or M). If the 
> latter, it's almost certainly from SPM2 (or 99), in which case, you 
> have a couple of options.
>
> You could convert the analyze+mat representation to a true NIfTI 
> image, with the affine transformation in the .hdr (or .nii headers). 
> Simply reading the image *with SPM5* and writing a new one should do 
> this, though you might want to write to a new filename to be safe:
>
>  V = spm_vol('blah.img');
>  img = spm_read_vols(V);
>  V.fname = 'blah_nifti.img';
>  spm_write_vol(V, img);
>
> Alternatively, you might want to resample the image, in which case the 
> header info will be much simpler, and could be stored in the header of 
> an Analyze image as well as the more flexible NIfTI headers. You can 
> use my MATLAB scripts (with SPM5 in your path to write NIfTI, or SPM2 
> to write Analyze, though I haven't tested the latter thoroughly):
>
>  http://www.cs.ucl.ac.uk/staff/gridgway/vbm/resize_img.m
>  http://www.cs.ucl.ac.uk/staff/gridgway/vbm/world_bb.m
>  http://www.cs.ucl.ac.uk/staff/gridgway/vbm/voxsize.m
>
> Just
>  resize_img('blah.img');
> on its own should do what you need, though you might like to change 
> the voxel sizes or bounding box at the same time (e.g. if you want 
> isotropic 1mm voxels, do this now, rather than 
> resampling/interpolating twice, with resize_img('blah.img', [1 1 1]);)
>
> I hope my guess is right, and that some of this helps,
>
> Ged.
>