questions > Change scanner position to Sphinx in dicom
Showing 1-4 of 4 posts
Display:
Results per page:
Jun 3, 2015  04:06 PM | alexander kraskov
Change scanner position to Sphinx in dicom
Hi,

we scan out subjects in sphinx position. But scanner does not have such option, which means that dicom files have wrong orientation, ie labels for Anterior and Superior are mixed up (essentially axial and coronal slices are mixed up).

Is it possible to modify dicom files afterwards in a way that dcm2nii will produce nifti with correct orientation, or is it possible to change axial and coronal slices in mricron and save nifti with correct orientation.

I don't want to do it with fsl swapdim because it destroys q matrix which I'd like to save.

Best wishes
Alexander

PS thank you for very informative response to my previous question
Jun 4, 2015  05:06 AM | Chris Rorden
RE: Change scanner position to Sphinx in dicom
Hello-
  I think you have two options. The easier one is to use SPM to adjust the matrix. I just checked this with SPM12 and it adjusts both the SForm and the QForm, which means software will see this regardless of whether they give precedence to the Matrix or Quaternion. The other way to achieve the same goal would be to add  the matrix multiplication (nifti_mat44_mul) to the "headerDcm2NiiSForm" function of dcm2niix's nii_dicom.cpp (https://github.com/neurolabusc/dcm2niix/...) and recompile your own copy of dcm2niix. 

Since I do not have a sample dataset, I am not sure exactly what transform you need, below I show swapping the Y and Z dimensions as an example. Make sure you check that your script does not flip the left and right dimension - due to the symmetry of the brain this can be confusing.

If you find my simple script below useful, you can find similar SPM utility scripts at https://github.com/neurolabusc/spmScripts 
The SPM team has done a great job of empowering tiny scripts...

-----------------------
SPM Matlab script follows
-----------------------
function nii_rotate_mat (fnm)
%rotate image by adjusting the NIfTI s-form
% fnm : (optional) image to rotate
%Example
% nii_rotate_mat('a.nii')
if ~exist('fnm','var')
fnm = spm_select(1,'image','Select image[s] to rotate');
end
hdr = spm_vol(fnm);
img = spm_read_vols(hdr);
hdr1 = hdr(1);
[pth nm ext] = spm_fileparts(fnm);
hdr1.fname = fullfile(pth, ['r' nm ext]);
hdr1.mat(1:3,1:4) = hdr1.mat(1:3,1:4)*10;
hdr1.mat = [1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1] * hdr1.mat;
for vol=1:size(img,4) %each volume of 4D data
hdr1.n(1)=vol;
spm_write_vol(hdr1,img(:, :, :, vol));
end;
%end nii_rotate_mat()
Jun 8, 2015  02:06 PM | alexander kraskov
RE: Change scanner position to Sphinx in dicom
Hi Chris,

thank you very much for you response, decided to go different way because realised that is FSL shows the date the way it is physically saved (one has to use flsswapdim to change it) and uses s-matrix only to re-calculate coordinates rather than to rotate image.
Moreover orientation labels which are shown by fslhd and in flsview are not independent from q and s-matrix and completely defined by them.

Never mind, thank your for help for pointing out to the source codes of dcm2nii (btw why readme.md on https://github.com/neurolabusc/dcm2niix says that dcm2nii converts "from the NIfTI format to the DICOM format" isn't it other way around).

I looked for into nii_rotate_mat script  and I am confused about this line
hdr1.mat(1:3,1:4) = hdr1.mat(1:3,1:4)*10;
why do you multiply by 10?

cheers
Jun 15, 2015  08:06 AM | Chris Rorden
RE: Change scanner position to Sphinx in dicom
Great. The script I sent you demonstrated how to rotate the image, but also included a zoom to change the voxel size. This is a standard convention for animal imaging, where users apply the zoom so the rat brain is approximately the same size as the human brain. The reasoning is that default values such as normalization regularization are tuned for a human size head. So the snippet I sent you was designed to convert a Bruker animal scan converted with pvconv (which exports to the older Analyze format that does not include rotation) for analysis with modern tools.