Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building template in ANTs #1745

Closed
ndescalco opened this issue May 15, 2024 · 6 comments
Closed

Building template in ANTs #1745

ndescalco opened this issue May 15, 2024 · 6 comments

Comments

@ndescalco
Copy link

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.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

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
Copy link
Member

cookpa commented May 15, 2024

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

100206_dti_fa.nii.gz

@ndescalco
Copy link
Author

ndescalco commented May 15, 2024

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
Copy link
Member

cookpa commented May 15, 2024

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

@ndescalco
Copy link
Author

template.csv
Here it is

@cookpa
Copy link
Member

cookpa commented May 16, 2024

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
Copy link
Member

cookpa commented May 16, 2024

It works normally for me after

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

@cookpa cookpa closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants