Registration of EPI data to template space - error

Dear SCT team,

I hope you are doing well!

I am trying to register my mean functional image to the PAM50 template space using sct_register_multimodal command (I tried two SCT versions: 4.3 and 5.7).
However, while running the registration, I do get the following warning:

Estimate cord angle for each slice:   0%|                                  | 0/12 [00:00<?, ?iter/s]WARNING: Slice #0 is empty. It will be ignored.
WARNING: Slice #1 is empty. It will be ignored.
WARNING: Slice #2 is empty. It will be ignored.
WARNING: Slice #3 is empty. It will be ignored.
WARNING: Slice #4 is empty. It will be ignored.
WARNING: Slice #5 is empty. It will be ignored.
WARNING: Slice #6 is empty. It will be ignored.
WARNING: Slice #7 is empty. It will be ignored.
WARNING: Slice #8 is empty. It will be ignored.
WARNING: Slice #9 is empty. It will be ignored.
WARNING: Slice #10 is empty. It will be ignored.
WARNING: Slice #11 is empty. It will be ignored.

And, I believe, when I check the mean EPI in the template space using fsleyes I do not see anything (there is nothing in the image) as a result of this warning.

I have tried: i) using different masks (one manually drawn, one created by SCT propseg), ii) using and NOT using -initwarp and -initwarpinv options (btw, the registration of T2-weighted image to the template space worked well), iii) using two different SCT versions (4.3 and 5.7). However, I encountered the same problem in any case. Could you please help me with this tissue?

Thank you very much!
Merve

Here is the command I used (note that I also had a version with -initwarp and -initwarpinv)

sct_register_multimodal -i /home/mkaptan/Documents/data/sctTemplates/data/PAM50/template/PAM50_t2s.nii.gz \
    -d /home/mkaptan/Documents/data/derivatives/sub-104/ses-01spinalcord/func/rest/RetroicorSliceTime/sub-104_ses-01spinalcord_task-rest_rec-RetroicorSliceTime_bold_mc3_mean.nii.gz \
    -iseg /home/mkaptan/Documents/data/sctTemplates/data/PAM50/template/PAM50_cord.nii.gz \
    -dseg /home/mkaptan/Documents/data/derivatives/sub-104/ses-01spinalcord/func/rest/RetroicorSliceTime/sub-104_ses-01spinalcord_task-rest_rec-RetroicorSliceTime_bold_mc3_mean_seg.nii.gz  \
    -param step=1,type=seg,algo=centermass:step=2,type=seg,algo=bsplinesyn,slicewise=1,iter=3

And here is the relevant SCT output:

Spinal Cord Toolbox (4.3)


Input parameters:
  Source .............. /home/mkaptan/Documents/data/sctTemplates/data/PAM50/template/PAM50_t2s.nii.gz
  Destination ......... /home/mkaptan/Documents/data/derivatives/sub-104/ses-01spinalcord/func/rest/RetroicorSliceTime/sub-104_ses-01spinalcord_task-rest_rec-RetroicorSliceTime_bold_mc3_mean.nii.gz
  Init transfo ........ 
  Mask ................ 
  Output name ......... 
  Remove temp files ... 1
  Verbose ............. 1

Check if input data are 3D...

Create temporary folder (/tmp/sct-20221102185608.424919-register-6axauc_p)...

Copying input data to tmp folder and convert to nii...

--
ESTIMATE TRANSFORMATION FOR STEP #0
Registration parameters:
  type ........... im
  algo ........... syn
  slicewise ...... 0
  metric ......... MI
  iter ........... 0
  smooth ......... 0
  laplacian ...... 0
  shrink ......... 1
  gradStep ....... 0.5
  deformation .... 1x1x0
  init ........... 
  poly ........... 5
  filter_size .... 5
  dof ............ Tx_Ty_Tz_Rx_Ry_Rz
  smoothWarpXY ... 2
  rot_method ..... pca

Estimate transformation
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 3 --transform 'syn[0.5,3,0]' --metric 'MI[dest_RPI.nii,src.nii,1,32]' --convergence 0 --shrink-factors 1 --smoothing-sigmas 0mm --restrict-deformation 1x1x0 --output '[step0,src_regStep0.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185608.424919-register-6axauc_p

--
ESTIMATE TRANSFORMATION FOR STEP #1

Apply transformation from previous step

Parse list of warping fields...

Get dimensions of data...
  141 x 141 x 991 x 1

Apply transformation...

Apply transformation and resample to destination space...
/home/cslaw/sct_4.3/bin/isct_antsApplyTransforms -d 3 -i src_seg.nii -o src_seg_reg.nii -t warp_forward_0.nii.gz -r dest_seg_RPI.nii -n NearestNeighbor # in /tmp/sct-20221102185608.424919-register-6axauc_p
Copy affine matrix from destination space to make sure qform/sform are the same.

Done! To view results, type:
fsleyes dest_seg_RPI.nii src_seg_reg.nii &

Registration parameters:
  type ........... seg
  algo ........... centermass
  slicewise ...... 0
  metric ......... MeanSquares
  iter ........... 10
  smooth ......... 0
  laplacian ...... 0
  shrink ......... 1
  gradStep ....... 0.5
  deformation .... 1x1x0
  init ........... 
  poly ........... 5
  filter_size .... 5
  dof ............ Tx_Ty_Tz_Rx_Ry_Rz
  smoothWarpXY ... 2
  rot_method ..... pca

Create temporary folder (/tmp/sct-20221102185610.699625-register-x3w3fvz5)...

Copy input data to temp folder...
sct_convert -i src_seg_reg.nii -o /tmp/sct-20221102185610.699625-register-x3w3fvz5/src.nii
sct_convert -i dest_seg_RPI.nii -o /tmp/sct-20221102185610.699625-register-x3w3fvz5/dest.nii

Get image dimensions of destination image...
  matrix size: 64 x 64 x 12
  voxel size:  1.25mm x 1.25mm x 5.0mm

Split input segmentation...

Split destination segmentation...
Estimate cord angle for each slice:   0%|                                  | 0/12 [00:00<?, ?iter/s]WARNING: Slice #0 is empty. It will be ignored.
WARNING: Slice #1 is empty. It will be ignored.
WARNING: Slice #2 is empty. It will be ignored.
WARNING: Slice #3 is empty. It will be ignored.
WARNING: Slice #4 is empty. It will be ignored.
WARNING: Slice #5 is empty. It will be ignored.
WARNING: Slice #6 is empty. It will be ignored.
WARNING: Slice #7 is empty. It will be ignored.
WARNING: Slice #8 is empty. It will be ignored.
WARNING: Slice #9 is empty. It will be ignored.
WARNING: Slice #10 is empty. It will be ignored.
WARNING: Slice #11 is empty. It will be ignored.
Estimate cord angle for each slice: 100%|████████████████████████| 12/12 [00:00<00:00, 184.43iter/s]
Build 3D deformation field: 0iter [00:00, ?iter/s]

Generate warping field...
 --> step1Warp.nii.gz

Generate warping field...
 --> step1InverseWarp.nii.gz

Move warping fields...
cp step1Warp.nii.gz /tmp/sct-20221102185608.424919-register-6axauc_p
cp step1InverseWarp.nii.gz /tmp/sct-20221102185608.424919-register-6axauc_p
rm -rf /tmp/sct-20221102185610.699625-register-x3w3fvz5

--
ESTIMATE TRANSFORMATION FOR STEP #2

Apply transformation from previous step

Parse list of warping fields...

Get dimensions of data...
  141 x 141 x 991 x 1

Apply transformation...

Apply transformation and resample to destination space...
/home/cslaw/sct_4.3/bin/isct_antsApplyTransforms -d 3 -i src_seg.nii -o src_seg_reg.nii -t warp_forward_1.nii.gz warp_forward_0.nii.gz -r dest_seg_RPI.nii -n NearestNeighbor # in /tmp/sct-20221102185608.424919-register-6axauc_p
Copy affine matrix from destination space to make sure qform/sform are the same.

Done! To view results, type:
fsleyes dest_seg_RPI.nii src_seg_reg.nii &

Registration parameters:
  type ........... seg
  algo ........... bsplinesyn
  slicewise ...... 1
  metric ......... MeanSquares
  iter ........... 3
  smooth ......... 0
  laplacian ...... 0
  shrink ......... 1
  gradStep ....... 0.5
  deformation .... 1x1x0
  init ........... 
  poly ........... 5
  filter_size .... 5
  dof ............ Tx_Ty_Tz_Rx_Ry_Rz
  smoothWarpXY ... 2
  rot_method ..... pca

Create temporary folder (/tmp/sct-20221102185611.097969-register-yd02c7p_)...

Copy input data to temp folder...
sct_convert -i src_seg_reg.nii -o /tmp/sct-20221102185611.097969-register-yd02c7p_/src.nii
sct_convert -i dest_seg_RPI.nii -o /tmp/sct-20221102185611.097969-register-yd02c7p_/dest.nii

Get image dimensions of destination image...
.. matrix size: 64 x 64 x 12
.. voxel size:  1.25mm x 1.25mm x 5.0mm

Split input volume...

Split destination volume...
Registering slice 0/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0000.nii,src_Z0000.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0000,src_Z0000_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 1/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0001.nii,src_Z0001.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0001,src_Z0001_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 2/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0002.nii,src_Z0002.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0002,src_Z0002_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 3/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0003.nii,src_Z0003.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0003,src_Z0003_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 4/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0004.nii,src_Z0004.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0004,src_Z0004_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 5/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0005.nii,src_Z0005.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0005,src_Z0005_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 6/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0006.nii,src_Z0006.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0006,src_Z0006_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 7/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0007.nii,src_Z0007.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0007,src_Z0007_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 8/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0008.nii,src_Z0008.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0008,src_Z0008_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 9/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0009.nii,src_Z0009.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0009,src_Z0009_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 10/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0010.nii,src_Z0010.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0010,src_Z0010_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_
Registering slice 11/11...
/home/cslaw/sct_4.3/bin/isct_antsRegistration --dimensionality 2 --transform 'BSplineSyN[0.5,1,3]' --metric 'MeanSquares[dest_Z0011.nii,src_Z0011.nii,1,4]' --convergence 3 --shrink-factors 1 --smoothing-sigmas 0mm --output '[warp2d_0011,src_Z0011_reg.nii]' --interpolation 'BSpline[3]' --verbose 1 # in /tmp/sct-20221102185611.097969-register-yd02c7p_

Merge warping fields along z...

Move warping fields...
cp step2Warp.nii.gz /tmp/sct-20221102185608.424919-register-6axauc_p
cp step2InverseWarp.nii.gz /tmp/sct-20221102185608.424919-register-6axauc_p
rm -rf /tmp/sct-20221102185611.097969-register-yd02c7p_

Concatenate transformations...

Parse list of warping fields...

Check file existence...
  OK: dest.nii
  OK: warp_forward_0.nii.gz
  OK: warp_forward_1.nii.gz
  OK: warp_forward_2.nii.gz
/home/cslaw/sct_4.3/bin/isct_ComposeMultiTransform 3 warp_final.nii.gz -R dest.nii warp_forward_2.nii.gz warp_forward_1.nii.gz warp_forward_0.nii.gz # in /tmp/sct-20221102185608.424919-register-6axauc_p

Generate output files...
  File created: warp_src2dest.nii.gz

Parse list of warping fields...

Check file existence...
  OK: src.nii
  OK: warp_inverse_2.nii.gz
  OK: warp_inverse_1.nii.gz
  OK: warp_inverse_0.nii.gz
/home/cslaw/sct_4.3/bin/isct_ComposeMultiTransform 3 warp_final.nii.gz -R src.nii warp_inverse_0.nii.gz warp_inverse_1.nii.gz warp_inverse_2.nii.gz # in /tmp/sct-20221102185608.424919-register-6axauc_p

Generate output files...
  File created: warp_dest2src.nii.gz

Apply transfo source --> dest...

Parse list of warping fields...

Get dimensions of data...
  141 x 141 x 991 x 1

Apply transformation...

Apply transformation and resample to destination space...
/home/cslaw/sct_4.3/bin/isct_antsApplyTransforms -d 3 -i src.nii -o src_reg.nii -t warp_src2dest.nii.gz -r dest.nii -n Linear # in /tmp/sct-20221102185608.424919-register-6axauc_p
Copy affine matrix from destination space to make sure qform/sform are the same.

Done! To view results, type:
fsleyes dest.nii src_reg.nii &


Apply transfo dest --> source...

Parse list of warping fields...

Get dimensions of data...
  64 x 64 x 12 x 1

Apply transformation...

Apply transformation and resample to destination space...
/home/cslaw/sct_4.3/bin/isct_antsApplyTransforms -d 3 -i dest.nii -o dest_reg.nii -t warp_dest2src.nii.gz -r src.nii -n Linear # in /tmp/sct-20221102185608.424919-register-6axauc_p
Copy affine matrix from destination space to make sure qform/sform are the same.

Hi Merve,

The EPI and the PAM50 templates are not in the same coordinate systems, so you need an initial warping field.

Now, you mentioned you already tried with an initial warping field, but maybe there is something wrong with that warping field (maybe the T2w and the EPI are not aligned?), or with the syntax you used.

If you share the T2w and the mean EPI files and all the syntaxes you used before sct_register_multimodal (segmentation, labeling, etc.), we will be able to find out what the problem is.

Julien

Hi Julien,

This was already super helpful and solved the problem! Thanks a lot :slight_smile: I was checking t2 in the template space which is fine but while organizing the data to send it to you, I did notice that T2w and EPI are indeed not aligned as you suggested.

Thank you very much again!
Merve

1 Like