ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.21k stars 381 forks source link

Building template in ANTs #1745

Closed ndescalco closed 6 months ago

ndescalco commented 6 months ago

Operating system and version

Ubuntu 22.04.4

CPU architecture

Unknown

ANTs code version

2.5.0.post43-g2d4c931

ANTs installation type

Compiled from source

Summary of the problem

I am using the 3T HCP dataset to build a multimodal template with T1w, T2w and FA images. When I am doing it i get the following error:

nelson@oliveira-maia-pc:/mnt/data1/nelson/STRUCTURAL_CONNECTOME/template$ antsMultivariateTemplateConstruction2.sh -d 3 -i 3 -k 3 -t SyN -r 1 -c 2 -o template template.csv

Multivariate template construction using the following 3-tuples:

100206_3T_T1w_MPR1_brain.nii.gz 100206_3T_T2w_SPC1_brain.nii.gz 100206_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gz 100307_3T_T1w_MPR1_brain.nii.gz 100307_3T_T2w_SPC1_brain.nii.gz 100307_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gz


Creating template templatetemplate0.nii.gz from a population average image from the inputs. 100206_3T_T1w_MPR1_brain.nii.gz 100307_3T_T1w_MPR1_brain.nii.gz

bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading 100206_3T_T1w_MPR1_brain.nii.gz reading 100307_3T_T1w_MPR1_brain.nii.gz writing output 1Sharpening method none Using double precision for computations. Input scalar image: 100206_3T_T1w_MPR1_brain.nii.gz Reference image: templatetemplate0.nii.gz

The composite transform comprises the following transforms (in order):

  1. ./initialCOM0_0_100206_3T_T1w_MPR1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM0_0_100206_3T_T1w_MPR1_brain.nii.gz Using double precision for computations. Input scalar image: 100307_3T_T1w_MPR1_brain.nii.gz Reference image: templatetemplate0.nii.gz

    The composite transform comprises the following transforms (in order):

  2. ./initialCOM0_1_100307_3T_T1w_MPR1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM0_1_100307_3T_T1w_MPR1_brain.nii.gz bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading ./initialCOM0_0_100206_3T_T1w_MPR1_brain.nii.gz reading ./initialCOM0_1_100307_3T_T1w_MPR1_brain.nii.gz writing output Sharpening method none


Creating template templatetemplate1.nii.gz from a population average image from the inputs. 100206_3T_T2w_SPC1_brain.nii.gz 100307_3T_T2w_SPC1_brain.nii.gz

bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading 100206_3T_T2w_SPC1_brain.nii.gz reading 100307_3T_T2w_SPC1_brain.nii.gz writing output Sharpening method none Using double precision for computations. Input scalar image: 100206_3T_T2w_SPC1_brain.nii.gz Reference image: templatetemplate1.nii.gz

The composite transform comprises the following transforms (in order):

  1. ./initialCOM1_0_100206_3T_T2w_SPC1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM1_0_100206_3T_T2w_SPC1_brain.nii.gz Using double precision for computations. Input scalar image: 100307_3T_T2w_SPC1_brain.nii.gz Reference image: templatetemplate1.nii.gz

    The composite transform comprises the following transforms (in order):

  2. ./initialCOM1_1_100307_3T_T2w_SPC1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM1_1_100307_3T_T2w_SPC1_brain.nii.gz bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading ./initialCOM1_0_100206_3T_T2w_SPC1_brain.nii.gz reading ./initialCOM1_1_100307_3T_T2w_SPC1_brain.nii.gz writing output Sharpening method none


Creating template templatetemplate2.nii.gz from a population average image from the inputs. _100307_data.src.gz.gqi.1.25.fib.gz.dtifa.nii.gzgz

Cannot read input file: 100206_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gz summarizeimageset: ERROR - output file templatetemplate2.nii.gz could not be created

I have confirmed and my template csv as the correct name files.

Any idea on how to solve this?

Commands to reproduce the problem.

antsMultivariateTemplateConstruction2.sh -d 3 -i 3 -k 3 -t SyN -r 1 -c 2 -o template template.csv

Output of the command with verbose output.

nelson@oliveira-maia-pc:/mnt/data1/nelson/STRUCTURAL_CONNECTOME/template$ antsMultivariateTemplateConstruction2.sh -d 3 -i 3 -k 3 -t SyN -r 1 -c 2 -o template template.csv

Multivariate template construction using the following 3-tuples:

100206_3T_T1w_MPR1_brain.nii.gz 100206_3T_T2w_SPC1_brain.nii.gz 100206_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gz 100307_3T_T1w_MPR1_brain.nii.gz 100307_3T_T2w_SPC1_brain.nii.gz 100307_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gz


Creating template templatetemplate0.nii.gz from a population average image from the inputs. 100206_3T_T1w_MPR1_brain.nii.gz 100307_3T_T1w_MPR1_brain.nii.gz

bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading 100206_3T_T1w_MPR1_brain.nii.gz reading 100307_3T_T1w_MPR1_brain.nii.gz writing output 1Sharpening method none Using double precision for computations. Input scalar image: 100206_3T_T1w_MPR1_brain.nii.gz Reference image: templatetemplate0.nii.gz

The composite transform comprises the following transforms (in order):

  1. ./initialCOM0_0_100206_3T_T1w_MPR1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM0_0_100206_3T_T1w_MPR1_brain.nii.gz Using double precision for computations. Input scalar image: 100307_3T_T1w_MPR1_brain.nii.gz Reference image: templatetemplate0.nii.gz

    The composite transform comprises the following transforms (in order):

  2. ./initialCOM0_1_100307_3T_T1w_MPR1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM0_1_100307_3T_T1w_MPR1_brain.nii.gz bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading ./initialCOM0_0_100206_3T_T1w_MPR1_brain.nii.gz reading ./initialCOM0_1_100307_3T_T1w_MPR1_brain.nii.gz writing output Sharpening method none


Creating template templatetemplate1.nii.gz from a population average image from the inputs. 100206_3T_T2w_SPC1_brain.nii.gz 100307_3T_T2w_SPC1_brain.nii.gz

bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading 100206_3T_T2w_SPC1_brain.nii.gz reading 100307_3T_T2w_SPC1_brain.nii.gz writing output Sharpening method none Using double precision for computations. Input scalar image: 100206_3T_T2w_SPC1_brain.nii.gz Reference image: templatetemplate1.nii.gz

The composite transform comprises the following transforms (in order):

  1. ./initialCOM1_0_100206_3T_T2w_SPC1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM1_0_100206_3T_T2w_SPC1_brain.nii.gz Using double precision for computations. Input scalar image: 100307_3T_T2w_SPC1_brain.nii.gz Reference image: templatetemplate1.nii.gz

    The composite transform comprises the following transforms (in order):

  2. ./initialCOM1_1_100307_3T_T2w_SPC1_brain.mat (type = TranslationTransform)

    Default pixel value: 0 Interpolation type: LinearInterpolateImageFunction Output warped image: ./initialCOM1_1_100307_3T_T2w_SPC1_brain.nii.gz bigimage 4 maxSize [256, 320, 320] Setting physical space of output average image based on largest image Averaging 2 images with dim = 3 vector components 1 reading ./initialCOM1_0_100206_3T_T2w_SPC1_brain.nii.gz reading ./initialCOM1_1_100307_3T_T2w_SPC1_brain.nii.gz writing output Sharpening method none


Creating template templatetemplate2.nii.gz from a population average image from the inputs. 100307_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gzgz

Cannot read input file: 100206_data.src.gz.gqi.1.25.fib.gz.dti_fa.nii.gz summarizeimageset: ERROR - output file templatetemplate2.nii.gz could not be created

Data to reproduce the problem

FA maps are obtained from DSI studio

cookpa commented 6 months ago

I reckon it's confused by the multiple extensions, can you try renaming to something like

100206_dti_fa.nii.gz

ndescalco commented 6 months ago

Yes, I did it and the error changes in the last part:


--------------------------------------------------------------------------------------
 Creating template templatetemplate1.nii.gz from a population average image from the inputs.
 100408_dti_fa.niiii
--------------------------------------------------------------------------------------
 Cannot read input file: 100206_dti_fa.nii
summarizeimageset: ERROR - output file templatetemplate1.nii.gz could not be created
cookpa commented 6 months ago

Can you upload template.csv? I'll see if I can reproduce

ndescalco commented 6 months ago

template.csv Here it is

cookpa commented 6 months ago
file template.csv
template.csv: ASCII text, with CRLF line terminators

I think this is the problem, there's carriage return characters in the file

cookpa commented 6 months ago

It works normally for me after

perl -i -pe 's/\r//g' template.csv