Open raacampbell opened 8 years ago
Hmmm.. Reading seems to work correctly
>> Aorig = mhd_read('~/atlas.mhd');
Then I can save and re-read an the results are the same:
>> mhd_write(Aorig,'atlas_write')
>> Areadwritten = mhd_read('atlas_write.mhd');
>> all(Aorig(:) == Areadwritten(:))
ans =
1
And atlas_write looks fine in Lasagna. In MATLAB these are int32 files and they are ints in the MHD.
However, if I run the in-house function atlasInSampleSpace
(which returns the transformed atlas [via transformix] to the workspace) then I get an int16 and things fuck up from there.
Ah, shit, it's transformix that's fucking this up:
$ transformix -in atlas.mhd -tp TransformParameters.1.txt -out ./
The result is toast. transformix is saving it as shorts even though the input mhd is listed as unit.
Things that seem to fix this:
(FinalBSplineInterpolationOrder 0)
(ResultImagePixelType "int")
The first stops it interpolating. The second is needed because the parameters were calculated with the template images, which are shorts.
looks like an integer overflow is happening