fslcreatehd should set ndims sensibly
This MR addresses two behavioural quirks in fslcreatehd
:
-
When creating a new image,
fslcreatehd
would previously always set the number of dimensions to 4, regardless of the specified value for the fourth dimension. This MR changes this behaviour so that if the specifiedtsize
is 0 or 1, the resulting image will have 3 dimensions. -
When modifying an existing image,
fslcreatehd
would previously always overwrite the sizes and pixdims of the first four dimensions, regardless of how many dimensions the image has. This MR changes this behaviour so that, if an image only has three dimensions,fslcreatehd
will only update the size and pixdims of the first three dimensions.
This change has come about by the discovery that when fslcreatehd is run on an existing 3D image with size (X, Y, Z)
, and the tsize field was set to 0, e.g.:
fslcreatehd X Y Z 0 .... <existing_3D_image>
it would set the number of dimensions of the existing image to 4 and, with the fourth dimension size equal to 0, would end up creating an empty image.
I'm planning to add some unit tests to fsl/pyfeeds-tests to validate the expected behaviour, so don't merge this until I've added the tests in.