Open joerlema opened 7 months ago
SPM expects the voxels, slicing and alignment to match perfectly between the mask and target image. In your case, the spatial transform is able to successfully align the images, but the images differ in these regards. You could use a tool like fslhd (e.g. fslhd flair.nii
) to inspect the dimensions and s-forms of your images.
Assuming your images are aligned with each other, you can reslice them with this simple script. The source image is your lesion map and the target is your FLAIR. This will reslice the lesion map to match the FLAIR. If you do use this script, I would also consider changing the default interpolation from:
interp = 1;%linear
to read
interp = 0;
This will use nearest neighbor interpolation, to prevent partial volume effects (e.g. voxels in the binary lesion map are either zero or one, not a mixture).
Thank you for your quick response. We checked the Niftii headers and the dimensions matched between lesion masks and scans. However, the sform matrices were different between the lesion masks and the scans. We fixed it by assigning the lesion mask the sform from the scan by using the following script:
%Read the metadata from NIfTI files
scan_file_name = 'P2_04082020_FLAIR';
lesion_file_name = 'P2_04082020_lesion';
scan_file_info = niftiinfo([scan_file_name, '.nii']);
lesion_file_info = niftiinfo([lesion_file_name, '.nii']);
%Read volumetric data from the file by using the file metadata.
V_lesion = niftiread(lesion_file_info);
%Copy the sform transform information from scan file
scan_file_transform_matrix = scan_file_info.Transform.T;
%Edit the sform transform information in lesion file
lesion_file_info.Transform.T = scan_file_transform_matrix;
%Write the volumetric data with the modified transform matrix to a new .nii file.
niftiwrite(V_lesion, [lesion_file_name, '_new.nii'], lesion_file_info);
This seemed to fix our problem. We were wondering if this is a good approach? We were able to complete the normalization using the clinical toolbox this way.
Dear all,
I have tried to use the 'Clinical' toolbox to normalize lesion maps that were drawn on FLAIR images in MRIcroN. However, when I try to run the script, I get the following error:
Error using spm_affreg (line 66) Source and its weighting image must have same orientation.
Both the lesion mask and the MRI scan have the same size. We created a reorientation matrix in SPM using the original scan to help with normalization.
When we display the lesion map onto the MRI scan, the orientation looks fine (see below).
However, we keep running into the same error. Could anyone provide insight into this problem?
P.S.: We have used the same approach and script for lesions that were drawn on DWI images, and did not encounter any issues there.