Skip to content

file name bug in antsMultivariateTemplateConstruction.sh #1932

@noah10

Description

@noah10

Operating system and version

Linux

CPU architecture

x86_64 (PC, Intel Mac, other Intel/AMD)

ANTs code version

2.5.0-g592625b

ANTs installation type

Downloaded Github release binaries

Summary of the problem

When doing rigid body registration (-r 1), line 993 of antsMultivariateTemplateConstruction.sh sets up a call to ANTS to perform registration and sets the name of the output file based on the complete name of the input file. This means that ANTS will set the name of the *Affine.txt file it generates based on the the complete name of the input file.

Unfortunately, in line 1011 it assumes that the Affine.txt filename will be built from the name of the input file truncated at the first dot in the filname, as defined in line 1010.

In practice this means that if your input file is something like "participant1.nii.gz" you'll be fine. If it is something like "sub-10095-5cc9e675a43e5f00368a1fad-1.3.12.2.1107.5.2.43.67025.2019050111054255647402353.0.0.0.nii.gz" , though, then the call at line 1011 will want to use something like "rigid113_0_subj-sub-10095-5cc9e675a43e5f00368a1fad-1Affine.txt" (notice that the 'Affine.txt' is appended right after the first '.' in the input filename) and won't be able to find it, resulting in an error like this:

HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0
:
  #000: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fdeprec.c line 156 in itk_H5Fis_hdf5(): unable to determine if file is accessible as HDF5
    major: File accessibility
    minor: Not an HDF5 file
  #001: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLcallback.c line 3769 in itk_H5VL_file_specific(): file specific failed
    major: Virtual Object Layer
    minor: Can't operate on object
  #002: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLcallback.c line 3699 in H5VL__file_specific(): file specific failed
    major: Virtual Object Layer
    minor: Can't operate on object
  #003: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLnative_file.c line 384 in itk_H5VL__native_file_specific(): error in HDF5 file check
    major: File accessibility
    minor: Unable to initialize object
  #004: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fint.c line 1073 in itk_H5F__is_hdf5(): unable to open file
    major: File accessibility
    minor: Unable to initialize object
  #005: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FD.c line 723 in itk_H5FD_open(): open failed
    major: Virtual File Layer
    minor: Unable to initialize object
  #006: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDsec2.c line 352 in H5FD__sec2_open(): unable to open file: name = './rigid113_0_subj-sub-10095-5cc9e675a43e5f00368a1fad-1Affine.txt', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0
    major: File accessibility
    minor: Unable to open file
Exception caught during WarpImageMultiTransform.

itk::ExceptionObject (0x63e5f526b300)
Location: "unknown" 
File: /home/runner/work/_temp/build/ITKv5/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx
Line: 122
Description: ITK ERROR: TxtTransformIOTemplate(0x63e5f52bb920): The file could not be opened for read access 
Filename: "./rigid113_0_subj-sub-10095-5cc9e675a43e5f00368a1fad-1Affine.txt"

For what it's worth, antsMultivariateTemplateConstruction2.sh does not appear to have this bug.

Commands to reproduce the problem.

/opt/ants-2.5.0/bin/antsMultivariateTemplateConstruction.sh -j 7 -g 0.15 -d 3 -i 4 -m 1x0x0 -w 1 -n 1 -k 1 -o full_template_ -c 2 -s CC -r 1 -b 0 -t GR -y 1 /input/subj-*-*.nii.gz

Output of the command with verbose output.


--------------------------------------------------------------------------------------
 Creating template full_template_template0.nii.gz from a population average image from the inputs.
   /input/subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz /input/subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
--------------------------------------------------------------------------------------
 bigimage 4 maxSize [176, 240, 256]
 Setting physical space of output average image based on largest image 
 Averaging 2 images with dim = 3 vector components 1
 reading /input/subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz
 reading /input/subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
 writing output 
Sharpening method none
Using double precision for computations.
Input scalar image: /input/subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz
Reference image: full_template_template0.nii.gz
=============================================================================
The composite transform comprises the following transforms (in order): 
  1. ./initialCOM0_0_subj-YA2-5b9c141562d9320011f1084a-1.mat (type = TranslationTransform)
=============================================================================
Default pixel value: 0
Interpolation type: LinearInterpolateImageFunction
Output warped image: ./initialCOM0_0_subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz
Using double precision for computations.
Input scalar image: /input/subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
Reference image: full_template_template0.nii.gz
=============================================================================
The composite transform comprises the following transforms (in order): 
  1. ./initialCOM0_1_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.mat (type = TranslationTransform)
=============================================================================
Default pixel value: 0
Interpolation type: LinearInterpolateImageFunction
Output warped image: ./initialCOM0_1_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
 bigimage 4 maxSize [176, 240, 256]
 Setting physical space of output average image based on largest image 
 Averaging 2 images with dim = 3 vector components 1
 reading ./initialCOM0_0_subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz
 reading ./initialCOM0_1_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
 writing output 
Sharpening method none

--------------------------------------------------------------------------------------
 Starting ANTS rigid registration on max 7 cpucores. 
 Progress can be viewed in ./job*_metriclog.txt
--------------------------------------------------------------------------------------
Using max 7 parallel threads
Running sh ./job_00_r.sh
Running sh ./job_01_r.sh
AFFINE: ./rigid1_0_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6Affine.txt
moving_image_filename: /input/subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz components 1
output_image_filename: ./rigid1_0_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
reference_image_filename: full_template_template0.nii.gz
[0/1]: AFFINE: ./rigid1_0_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6Affine.txt
AFFINE: ./rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1Affine.txt
moving_image_filename: /input/subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz components 1
output_image_filename: ./rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz
reference_image_filename: full_template_template0.nii.gz
[0/1]: AFFINE: ./rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1Affine.txt
User Linear interpolation 
 You are doing something more complex -- we wont check syntax in this case 
output origin: [118.686, 126.854, -87.7271]
output size: [176, 240, 256]
output spacing: [1.2, 1, 1]
output direction: -0.993915 0.0362486 -0.104017
-0.00966189 -0.969352 -0.245484
-0.109728 -0.242985 0.963804

User Linear interpolation 
HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0:
  #000: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fdeprec.c line 156 in itk_H5Fis_hdf5(): unable to determine if file is accessible as HDF5
    major: File accessibility
    minor: Not an HDF5 file
  #001: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLcallback.c line 3769 in itk_H5VL_file_specific(): file specific failed
    major: Virtual Object Layer
    minor: Can't operate on object
  #002: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLcallback.c line 3699 in H5VL__file_specific(): file specific failed
    major: Virtual Object Layer
    minor: Can't operate on object
  #003: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLnative_file.c line 384 in itk_H5VL__native_file_specific(): error in HDF5 file check
    major: File accessibility
    minor: Unable to initialize object
  #004: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fint.c line 1073 in itk_H5F__is_hdf5(): unable to open file
    major: File accessibility
    minor: Unable to initialize object
  #005: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FD.c line 723 in itk_H5FD_open(): open failed
    major: Virtual File Layer
    minor: Unable to initialize object
  #006: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDsec2.c line 352 in H5FD__sec2_open(): unable to open file: name = './rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1Affine.txt', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0
    major: File accessibility
    minor: Unable to open file
Exception caught during WarpImageMultiTransform.

itk::ExceptionObject (0x634139bb9030)
Location: "unknown" 
File: /home/runner/work/_temp/build/ITKv5/Modules/IO/TransformInsightLegacy/src/itkTxtTransformIO.cxx
Line: 122
Description: ITK ERROR: TxtTransformIOTemplate(0x634139c023e0): The file could not be opened for read access 
Filename: "./rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1Affine.txt"


HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0:
  #000: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fdeprec.c line 156 in itk_H5Fis_hdf5(): unable to determine if file is accessible as HDF5
    major: File accessibility
    minor: Not an HDF5 file
  #001: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLcallback.c line 3769 in itk_H5VL_file_specific(): file specific failed
    major: Virtual Object Layer
    minor: Can't operate on object
  #002: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLcallback.c line 3699 in H5VL__file_specific(): file specific failed
    major: Virtual Object Layer
    minor: Can't operate on object
  #003: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5VLnative_file.c line 384 in itk_H5VL__native_file_specific(): error in HDF5 file check
    major: File accessibility
    minor: Unable to initialize object
  #004: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5Fint.c line 1073 in itk_H5F__is_hdf5(): unable to open file
    major: File accessibility
    minor: Unable to initialize object
  #005: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FD.c line 723 in itk_H5FD_open(): open failed
    major: Virtual File Layer
    minor: Unable to initialize object
  #006: /home/runner/work/_temp/build/ITKv5/Modules/ThirdParty/HDF5/src/itkhdf5/src/H5FDsec2.c line 352 in H5FD__sec2_open(): unable to open file: name = './rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1Affine.txt', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0
    major: File accessibility
    minor: Unable to open file

AverageImages 3 full_template_template0.nii.gz 2 ./rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz ./rigid1_0_subj-sub-10039-65f3468c7937a02e6668f4f2-1_3_12_2_1107_5_2_43_67025_2024031411344164356502353_0_0_0_anat-T1w_acq-mprage_20240314111132_6.nii.gz
 Cannot read input file: ./rigid0_0_subj-YA2-5b9c141562d9320011f1084a-1.3.12.2.1107.5.2.43.67025.2018091412383081618797809.0.0.0.nii.gz
summarizeimageset: ERROR - output file full_template_template0.nii.gz could not be created

Data to reproduce the problem

Any T1w nifti files named as shown in the output above should suffice to reproduce this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions