Just as a followup, in case I did not provide enough info in my previous post this is a simple 2-step example that should replicate this potential bug:
note: in this example, the file 'foo.nii' contains multiple scans, and all of them have originally the same voxel-to-world mapping:
-3 0 0 102
0 3 0 -101
0 0 3 -27
0 0 0 1
1) First modify the voxel-to-world mapping of the first scan only:
>> M = spm_get_space( 'foo.nii,1' );
>> spm_get_space( 'lfo.nii,1' , diag([-1 -1 -1 1])*M );
>> a = spm_vol( 'lfo.nii' );
>> disp(a(1).mat); % display first scan orientation
3 0 0 -102
0 -3 0 101
0 0 -3 27
0 0 0 1
>> disp(a(end).mat); % display last scan orientation
-3 0 0 102
0 3 0 -101
0 0 3 -27
0 0 0 1
2) So far so good, the first scan as been flipped as expected. But now try reverting the voxel-to-world mapping (of the first scan only) to its original value, simply by repeating the step above:
>> M = spm_get_space( 'foo.nii,1' );
>> spm_get_space( 'lfo.nii,1' , diag([-1 -1 -1 1])*M );
>> a = spm_vol( 'lfo.nii' );
>> disp(a(1).mat); % display first scan orientation
-3 0 0 102
0 3 0 -101
0 0 3 -27
0 0 0 1
>> disp(a(end).mat); % display last scan orientation
3 0 0 -102
0 -3 0 101
0 0 -3 27
0 0 0 1
the first scan has been flipped back to its original value, but now "magically" the last scan has been flipped as well!
Hope this helps and please let me know your thoughts (and/or if the proposed modification in my previous post would seem appropriate)
Best regards
Alfonso
|