hope you are doing well. I’m still new to sct software and excited to use it as a main tool to analyse my Ex-vivo dwi dataset.
I wonder how I may solve the following issue to align dwi dataset with T1 mask orientation (RPI)?
T1 dataset and (DWI) were scanned in the sme space. So,I resampled the dwi dataset to T1 resol. Then I tried to re-orient my dwi data to RPI orientation to use T1 mask to generate dwi template but unfortunately it didn’t seem to work out.
I followed the following steps:
I used the following commands for T1 dwi dataset to get RPI orientation that matches the mask. Please see screenshots when I tried to overlay the dwi and t1 dataset with Charleys’ mask (nothing were changed). sct_image -i dwi_top_resampled.nii.gz -setorient RPI dwi_top_resampled_RPI.nii.gz
I checked the orientation for all dataset using sct_getorient and fslinfo I got that the orientations and resolutions are alright. (please see the screenshots below).
Just checking in to see how I can help. Would you like to send me 1-2 images so I can check on my end how to tune the registration? You can send it to me via email if the data cannot be publicly disclosed.
I did share dataset via email. Let me know please if further information is needed.
The link didn’t work-- see my email.
by the way, I wonder whether SCT tools could handle to straighten 4D dwi dataset or not.
To straighten a 4D volume, you can first estimate the curve2straight warping field using a 3D data, and then apply it to the 4D volume. Below is an example code:
# Download example data
sct_download_data -d sct_example_data
# Go to DWI folder
cd sct_example_data/dmri/
# Separate b=0 and DWI and average
sct_dmri_separate_b0_and_dwi -i dmri.nii.gz -bvec bvecs.txt
# Segment cord
sct_deepseg_sc -i dmri_dwi_mean.nii.gz -c dwi
# Straighten DWI mean data
sct_straighten_spinalcord -i dmri_dwi_mean.nii.gz -s dmri_dwi_mean_seg.nii.gz
# Apply straightening to 4D dmri data
sct_apply_transfo -i dmri.nii.gz -d straight_ref.nii.gz -w warp_curve2straight.nii.gz
Thank you very much @jcohenadad. It’s very robust method and is working very well now.
In regard to the dataset, a link has been sent to your email. Let me know please if there is any issues while downloading.
I successfully downloaded the data but didn’t have a chance to look at them yet (been very busy lately). I promise I will come back to you within the next few days.
I had a look at the images you sent me. First of all, I noticed that 4225_top_sc.nii.gz is not the segmentation of 4225_top_1.nii but of another image. In order to register your DWI scans to 4225_top_sc.nii.gz, I would also need the image that this mask is based on.
Also, I noticed that the two masks are flipped A-P:
Which means that one set of images has wrong headers. It is likely the dwi_top_mask.nii.gz (and its mask and 4225_top_1.nii), because the ventral horn are pointing towards “P” (it should be “A”).
So:
could you please also send me the image for 4225_top_sc.nii.gz
if you’d like me to also register 4225_top_1.nii to the DWI, let me know. I don’t need the mask for this image because the two images are already very close.
if you could fix the header information that would be great.
Thank you very much for your valuable information. I re-sent all data via email including T1 that belongs to the mask you had already. Could you please also re-produce -setorient RPI and sct_deepseg/straightening as well from your side?
I tested these options but results did not look good.
They are the same but the mask for t1 is oriented in RPI. So, I tried to re-orient the dwi/t1 to RPI but did not work out. I think there was something wrong from my side.
Please see the output for the data orientation
s4333238@cai-wks1:/30days/s4333238/TEST_MRTRIX_POPU_TEMPLATE/top_bott_updated/4225/top$ sct_image -i 4225_dwi_top.nii.gz -getorient
--
Spinal Cord Toolbox (4.2.0)
ASL
s4333238@cai-wks1:/30days/s4333238/TEST_MRTRIX_POPU_TEMPLATE/top_bott_updated/4225/top$ sct_image -i 4225_top_1.nii -getorient
--
Spinal Cord Toolbox (4.2.0)
pixdim[0] (qfac) should be 1 (default) or -1; setting qfac to 1
pixdim[0] (qfac) should be 1 (default) or -1; setting qfac to 1
LPI
s4333238@cai-wks1:/30days/s4333238/TEST_MRTRIX_POPU_TEMPLATE/top_bott_updated/4225/top$ sct_image -i 4225_top_sc.nii.gz -getorient
--
Spinal Cord Toolbox (4.2.0)
RPI
s4333238@cai-wks1:/30days/s4333238/TEST_MRTRIX_POPU_TEMPLATE/top_bott_updated/4225/top$
I think I’m facing the similar problem as this one
sct_image -setorient only alters the qform/sform of the header, not the actual data. In your case, the header is inconsistent with the data orientation, so you need to enforce another orientation between your data and the header-- this is done using the setorient-data flag. See below (red: before, green: after):
I ran this:
sct_image -i 4225_top_sc.nii.gz -setorient-data RAI -o 4225_top_sc_RAI.nii.gz
Now I am wondering why the mask had a wrong orientation at the first place. You mentioned it is “Charley’s mask”: but how was it produced? What command?
There are also problems with the file 4225_top_1.nii: some fields which are wrong, e.g. pixdim0:
filename 4225_top_1.nii
size of header 348
data_type UINT16
dim0 3
dim1 256
dim2 256
dim3 1024
dim4 0
dim5 0
dim6 0
dim7 0
vox_units mm
time_units s
datatype 512
nbyper 2
bitpix 16
pixdim0 0.000000 --> WRONG VALUE
Also, the file 4225_dwi_top.nii.gz has forbidden values in the header:
filename 4225_dwi_top.nii.gz
size of header 348
data_type UINT16
dim0 4
dim1 128
dim2 512
dim3 128
dim4 20
dim5 1
dim6 1
dim7 1
vox_units mm
time_units s
datatype 512
nbyper 2
bitpix 16
pixdim0 1.000000
pixdim1 0.156250
pixdim2 0.156250
pixdim3 0.156250
pixdim4 nan --> WRONG VALUE
I would strongly recommend using neuroimaging apps that keep the integrity of the image headers, otherwise you will end up with unexpected consequences.
Now that the masks are properly oriented, we can straighten: