Neurological vs radiological

I have a nifti image and i had printed the properties too.Dimension of this image is 39x305x305
Is it possible to change the dimension to 305x305x39 so that number of slices are 39.can you suggest a way to manipulate it. is it radiological or neurological?
affine transormation i got is
2 0 0 -0.5
0 1.25 0 0
0 0 1.25 0
0 0 0 1

import nibabel as nib
img = nib.load("/home/leena/Desktop/Sub1.nii")
print(img.shape)
print(img.header)

sizeof_hdr : 348

data_type :
db_name :
extents : 0
session_error : 0
regular : r
dim_info : 0
dim : [ 3 39 305 305 0 0 0 0]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : int16
bitpix : 16
slice_start : 0
pixdim : [ 1. 2. 1.25 1.25 0. 0. 0. 0. ]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 0
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip :
aux_file :
qform_code : scanner
sform_code : unknown
quatern_b : 0.0
quatern_c : 0.0
quatern_d : 0.0
qoffset_x : -0.499992370605
qoffset_y : 0.0
qoffset_z : 0.0
srow_x : [ 0. 0. 0. 0.]
srow_y : [ 0. 0. 0. 0.]
srow_z : [ 0. 0. 0. 0.]
intent_name :
magic : n+1

What tool was used to generate this NIfTI image? This looks very unusual - if your raw data is in DICOM or PAR/REC format, I would recommend using dcm2niix or dicm2nii to generate new NIfTI images.

  • The values scl_slope : nan andscl_inter : nan are likely to cause you problems. These values scale the raw brightness saved to disk to a true value. A not-a-number value is clearly wrong. At a minimum, I would set this to be scl_slope : 1.0 andscl_inter : 0.0 (setting the slope to one and the intercept to zero means that the computed brightness is identical to what is saved to disk.
  • dcm2niix and dicm2nii will typically rotate your 3D acquisitions to be losslessly rotated to match NIfTI identity matrix. If your data is an axial acquisition with a 305x305 in plane matrix and 35 slices (with successive slices in the 3rd, Z dimension), than the output will have the dim [3 305 305 39 …], on the other hand, if your data was a sagittal acquisition (with successive slices in the first, X dimension), the dim will remain [3 39 305 305 …]. The issue with the sample you provided is that the current header suggests that this was a sagittal acquisition, further the header suggests just 2mm between voxel centers in the slice direction, yielding just 78mm in this dimension. This suggests only partial coverage of the human brain.
  • My sense is that you need to use a different tool to convert your raw files to NIfTI format. I suspect that the tool you used only measured the slice thickness, and ignored the slice gap. That would explain why you do not appear to have whole brain coverage.
  • The SPM script nii_reorient will take a NIfTI input image and rotate it to losslessly match the nearest orthogonal to NIfTI identity space (with the residual saved in your q-form and s-form). However, this assumes your image has a valid spatial transform, which I doubt is the case.
  • Regarding radiological or neurological space, please see this page on
    NIfTI coordinates.

I don’t know which tool they had used to generate this NIFTI image of spine MRI. I got it as nii format. Can you help me how to format it. what are the arguments of nii_reorient ? I have been searching several months for the solution

Or can you share some spine MRI. My aim is to detect degenerate disc

You could use SPM’s “Display” function to set the correct rotation and origin. Hopefully your image has a fiducial or some other marker that helps you distinguish the left from right hemisphere. Yakovlevian torque provides a rule of thumb here, but its probabilistic. Hopefully that will be smart enough to convert the NaN scale/slope value to real values. If not you can edit the header with MRIcron (View/Information). Since it sounds like you are working with a spine image and not a brain, I have no idea if the slice thickness takes gap into account.

You may want to look foropen source DICOM datasets and use dcm2niix or dicm2nii to convert them. I think several of those have CT images that include the spine. For MRI scans, we tend to tune the parameters of the scanner depending on what we are looking for, so I am not sure any of those databases are ideal. MRI scans are routinely used for diagnosis of disc and facet injury. Maybe your IRB can work out anonymized access for a local dataset.

I tried nii_orient and MRICRon header display. Left and Right are flipped.but the dimension is not changing.please help me

If you want to change the other dimensions, you need to specify the correct orientation in your SForm. You can do this manually with MRIcron’s Window/Information tab, e.g. an orthogonal rotation of the X and Y axis might look like this:
0 1 0
1 0 0
0 0 1
However, it is hard to visualize these transforms. An alternative is to open your image with a recent build of MRIcroGL. Choose Import/RotateVolume and answer a few questions. This will set up your SForm correctly. If the software you are using to analyze your data is SForm-aware, you should be good to go. If not, you can apply ini_orient on the volume to rotate it as directly in the SForm.

dimension of my image is 39x305x305. I think I need to swap z and x.;since i need a 305x305x39. But I have no idea about the other.whether it is flipped or not.Please suggest a rotation matrix for nii_reorient
Kindly give me your mail id so that i can send you the .nii image

I tried MRIcroGL and rotate. Now S-form is changed and I got the following properties. Still dimension is not changed

(39, 305, 305)
[[ 0. 0. 1.25 0. ]
[-1.99999976 0. 0. 0.49999237]
[ 0. 1.25 0. 0. ]
[ 0. 0. 0. 1. ]]
<class ‘nibabel.nifti1.Nifti1Header’> object, endian=’<’
sizeof_hdr : 348
data_type :
db_name :
extents : 0
session_error : 0
regular : r
dim_info : 0
dim : [ 3 39 305 305 1 1 0 0]
intent_p1 : 0.0
intent_p2 : 0.0
intent_p3 : 0.0
intent_code : none
datatype : int16
bitpix : 16
slice_start : 0
pixdim : [-1. 1.99999976 1.25 1.25 0. 0. 0.
0. ]
vox_offset : 0.0
scl_slope : nan
scl_inter : nan
slice_end : 0
slice_code : unknown
xyzt_units : 0
cal_max : 0.0
cal_min : 0.0
slice_duration : 0.0
toffset : 0.0
glmax : 0
glmin : 0
descrip :
aux_file :
qform_code : scanner
sform_code : scanner
quatern_b : 0.5
quatern_c : -0.5
quatern_d : -0.5
qoffset_x : 0.0
qoffset_y : 0.499992370605
qoffset_z : 0.0
srow_x : [ 0. 0. 1.25 0. ]
srow_y : [-1.99999976 0. 0. 0.49999237]
srow_z : [ 0. 1.25 0. 0. ]
intent_name :
magic : n+1

Whether i need to apply nii_reorient after rotating from MRIcroGL

I do X and Y rotation using
M=[0 1 0;1 0 0;0 0 1]
nii_reorient(“Sub.nii”,M)
then I do Y and Z rotation using
M=[1 0 0;0 0 1;0 1 0]
nii_reorient(“Sub.nii”,M)

Now dimension is changed to 305X305x39 .but when I viewed this from MRIcron, axial one becomes sagittal. Please help me