Register template to MT1

Dear all
When I wanna register template to MT1

(venv_sct) forest@DESKTOP-DM8SQ21:~/sct_course_london20/single_subject/data/mt$ sct_register_multimodal -i $SCT_DIR/data/PAM50/template/PAM50_t2.nii.gz -iseg $SCT_DIR/data/PAM50/template/PAM50_cord.nii.gz -d mt1.nii.gz -dseg mt1_seg.nii.gz -param step=1,type=seg,algo=centermass:step=2,type=seg,algo=bsplinesyn,slicewise=1,iter=3 -m mask_mt1.nii.gz -initwarp ../t2/warp_template2anat.nii.gz -qc ~/qc_singleSubj

--
Spinal Cord Toolbox (git-HEAD-95e66208c9d6937fbe00e86db6176e4001196e56)

sct_register_multimodal -i /home/forest/sct/data/PAM50/template/PAM50_t2.nii.gz -iseg /home/forest/sct/data/PAM50/template/PAM50_cord.nii.gz -d mt1.nii.gz -dseg mt1_seg.nii.gz -param step=1,type=seg,algo=centermass:step=2,type=seg,algo=bsplinesyn,slicewise=1,iter=3 -m mask_mt1.nii.gz -initwarp ../t2/warp_template2anat.nii.gz -qc /home/forest/qc_singleSubj
--


Input parameters:
  Source .............. /home/forest/sct/data/PAM50/template/PAM50_t2.nii.gz
  Destination ......... mt1.nii.gz
  Init transfo ........ /home/forest/sct_course_london20/single_subject/data/t2/warp_template2anat.nii.gz
  Mask ................ mask_mt1.nii.gz
  Output name .........
  Remove temp files ... 1
  Verbose ............. 1

Check if input data are 3D...
Creating temporary folder (/tmp/sct-20210314155235.140940-register-2ddrhwao)

Copying input data to tmp folder and convert to nii...
File mask.nii.gz already exists. Will overwrite it.

Skip step=0 and replace with initial transformations:
  /home/forest/sct_course_london20/single_subject/data/t2/warp_template2anat.nii.gz

WARNING: No initial inverse warping field was specified, therefore the inverse warping field will NOT be generated.

--
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/forest/sct/bin/isct_antsApplyTransforms -d 3 -i src_seg.nii -o src_seg_reg.nii -t /home/forest/sct_course_london20/single_subject/data/t2/warp_template2anat.nii.gz -r dest_seg_RPI.nii -n NearestNeighbor # in /tmp/sct-20210314155235.140940-register-2ddrhwao
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
  samplStrategy .. None
  samplPercent ... 0.2
  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

WARNING: algo centermass will ignore the provided mask.

Creating temporary folder (/tmp/sct-20210314155237.775890-register-2xx86ulq)

Copy input data to temp folder...

Get image dimensions of destination image...
  matrix size: 192 x 192 x 22
  voxel size: 0.8958333mm x 0.8958333mm x 22mm

Split input segmentation...

Split destination segmentation...
Estimate cord angle for each slice: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 22/22 [00:00<00:00, 1096.48iter/s]
Build 3D deformation field: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 22/22 [00:02<00:00,  8.86iter/s]

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

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

Move warping fields...
cp step1Warp.nii.gz /tmp/sct-20210314155235.140940-register-2ddrhwao
cp step1InverseWarp.nii.gz /tmp/sct-20210314155235.140940-register-2ddrhwao
rm -rf /tmp/sct-20210314155237.775890-register-2xx86ulq

--
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/forest/sct/bin/isct_antsApplyTransforms -d 3 -i src_seg.nii -o src_seg_reg.nii -t warp_forward_1.nii.gz /home/forest/sct_course_london20/single_subject/data/t2/warp_template2anat.nii.gz -r dest_seg_RPI.nii -n NearestNeighbor # in /tmp/sct-20210314155235.140940-register-2ddrhwao
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
  samplStrategy .. None
  samplPercent ... 0.2
  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
Creating temporary folder (/tmp/sct-20210314155242.159604-register-ms0j57mm)

Copy input data to temp folder...
Traceback (most recent call last):
  File "/home/forest/sct/spinalcordtoolbox/scripts/sct_register_multimodal.py", line 430, in <module>
    main(sys.argv[1:])
  File "/home/forest/sct/spinalcordtoolbox/scripts/sct_register_multimodal.py", line 409, in main
    path_out=path_out)
  File "/home/forest/sct/spinalcordtoolbox/scripts/sct_register_to_template.py", line 1033, in register_wrapper
    warp_forward_out, warp_inverse_out = register(src=src, dest=dest, step=step, param=param)
  File "/home/forest/sct/spinalcordtoolbox/scripts/sct_register_to_template.py", line 1226, in register
    verbose=param.verbose,
  File "/home/forest/sct/spinalcordtoolbox/registration/register.py", line 282, in register_step_slicewise_ants
    verbose=verbose
  File "/home/forest/sct/spinalcordtoolbox/registration/register.py", line 373, in register_slicewise
    image.convert(fname_mask, os.path.join(path_tmp, "mask.nii.gz"))
  File "/home/forest/sct/spinalcordtoolbox/image.py", line 1345, in convert
    img.data = np.squeeze(img.data)
AttributeError: 'str' object has no attribute 'data'

error occured

Hi @chang. Thank you very much for reporting this. This is a bug in SCT. A bug report has been opened here: https://github.com/neuropoly/spinalcordtoolbox/issues/3282

This issue is being treated with high priority. We will let you know when a fix is released. :slightly_smiling_face:

Kind regards,
Joshua

Thank you very much and look forward to your solution!

Hi joshuacwnewton
Now what can I do to avoid this bug?

Hi @chang. A fix for this bug has now been merged into the source code of the project.

However, a new version of SCT has not been released yet, because there are some other bug fixes that need to be completed first. So, you have two options:

  • Wait until a new version of SCT has been released, then install the new version.
  • Install the development version of SCT, following the instructions from the β€œInstall from GitHub (development)” section of our documentation.

Thank you for your patience. :slightly_smiling_face:

1 Like