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

Issue running LabelGeometryMeasures without including optional intensity image #1522

Closed
EvPhD opened this issue Apr 6, 2023 · 9 comments · Fixed by #1530
Closed

Issue running LabelGeometryMeasures without including optional intensity image #1522

EvPhD opened this issue Apr 6, 2023 · 9 comments · Fixed by #1530

Comments

@EvPhD
Copy link

EvPhD commented Apr 6, 2023

Hi Team,

I'm new to posting on forums so hope I'm in the right place. I have searched for similar issues but haven't found one that has answered my problem. Just for some background: I am running a lesion simulation study to see if a specific lesion filling tool improves parcellation accuracy in regions outside of the lesioned area. I have run the lesion filling tool and Fastsurfer on our T1w images and then used fslmaths and mrcalc to remove the lesioned region from all of the label images. I am now trying to use LabelGeometryMeasures to generate the volume in each region and save it in a .csv file so that I can then calculate percent volume difference across the images with and without lesion filling.

Unfortunately, when I try to run LabelGeometryMeasures using the command below, I get the following error. We are thinking it is trying to read our specified output file as as the optional intensity image input file? Despite this error it does go on to print the output in the terminal (I didn't include all of the output in the section copied below) but it doesn't save it as a .csv which I need. I also tried running the command again providing a path to a T1w image (in the same space as the label image) for the optional 'intensity image' and then specifying the output file and it ran successfully and saved to .csv, but I am not sure if the image I am providing as the 'intensity image' is the correct one given the image manipulation I have done in previous steps. I would like to be able to have it run without the intensity image if possible, but if it can't could you please provide some clarification around what the intensity image should be. I am running on our local HPC cluster and ANTs version 2.3.4.

Thank you in advance for your help. Apologies if there's more information needed that I haven't provided, happy to look up and provide whatever's needed.

[evelynd@m3t105 Test2]$ for i in sub-r0073.1_in_0822.1; do

LabelGeometryMeasures 3 $datadir/stats_out/${i}/${i}_SME_nolesion.nii.gz $datadir/stats_out/${i}/${i}_SME_LGM.csv

done
Exception caught during reference file reading

itk::ImageFileReaderException (0x55838b1d4ac0)
Location: "unknown"
File: /opt/mrtrix3/ANTs/build/ITKv5-install/include/ITK-5.0/itkImageFileReader.hxx
Line: 142
Description: Could not create IO object for reading file /home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2/stats_out/sub-r0073.1_in_0822.1/sub-r0073.1_in_0822.1_SME_LGM.csv
Tried to create one of the following:
BMPImageIO
BioRadImageIO
Bruker2dseqImageIO
GDCMImageIO
GE4ImageIO
GE5ImageIO
GiplImageIO
HDF5ImageIO
JPEGImageIO
LSMImageIO
MGHImageIO
MINCImageIO
MRCImageIO
MetaImageIO
NiftiImageIO
NrrdImageIO
PNGImageIO
StimulateImageIO
TIFFImageIO
VTKImageIO
You probably failed to set a file suffix, or
set the suffix to an unsupported type.

file /home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2/stats_out/sub-r0073.1_in_0822.1/sub-r0073.1_in_0822.1_SME_LGM.csv
Label Volume(voxels)SurfArea(mm^2) Eccentricity Elongation Orientation Centroid Axes Length Bounding Box
2 257832 107948 0.935689 2.83426 1.56142 [152.972, 110.99, 136.463] [52.9135, 88.3005, 149.971] [123, 192, 35, 204, 77, 192]
4 10086 5129.92 0.990085 7.11887 1.78568 [139.392, 120.302, 133.333] [17.4427, 29.1, 124.172] [126, 158, 58, 170, 110, 147]

@cookpa
Copy link
Member

cookpa commented Apr 11, 2023

LabelGeometryMeasures 3 $datadir/stats_out/${i}/${i}_SME_nolesion.nii.gz $datadir/stats_out/${i}/${i}_SME_LGM.csv

Does it work if you use the suggested default?

LabelGeometryMeasures 3 \
  $datadir/stats_out/${i}/${i}_SME_nolesion.nii.gz \
  none \
  $datadir/stats_out/${i}/${i}_SME_LGM.csv

@EvPhD
Copy link
Author

EvPhD commented Apr 11, 2023

Thanks for your suggestion, this is what I just ran and the error it produced:

LabelGeometryMeasures 3
$datadir/stats_out/${i}/${i}_SME_nolesion.nii.gz
none
$datadir/stats_out/${i}/${i}_SME_LGM.csv
file none does not exist

@gdevenyi
Copy link
Contributor

Can you please check

  1. You are using bash
  2. This happens with a manually specified single command without a loop

@EvPhD
Copy link
Author

EvPhD commented Apr 11, 2023

Thanks for checking and sorry about the confusion. Yes I am using Bash (unsure why some of the syymbols may be displaying differently in these comments). I have tried running the ammended command as part of my larger script and within it's own loop below. I just copied the actual command for my pevious comment but did actually run it in the loop below. I have now tested with the command outside a loop command and error also below:

Loop Command and Error:
[evelynd@m3t106 Test2]$ datadir="/home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2"
[evelynd@m3t106 Test2]$ cd $datadir
[evelynd@m3t106 Test2]$
[evelynd@m3t106 Test2]$ for i in sub-r0073.1_in_0822.1; do

LabelGeometryMeasures 3
$datadir/stats_out/${i}/${i}_SME_nolesion.nii.gz
none
$datadir/stats_out/${i}/${i}_SME_LGM.csv

done
file none does not exist .

Single Command and Error:
[evelynd@m3t106 Test2]$ LabelGeometryMeasures 3 /home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2/stats_out/sub-r0073.1_in_0822.1/sub-r0073.1_in_0822.1_SME_nolesion.nii.gz \ none \ /home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2/stats_out/sub-r0073.1_in_0822.1/sub-r0073.1_in_0822.1_SME_LGM.csv
file none does not exist .
Exception caught!

itk::ExceptionObject (0x7fba240066b0)
Location: "unknown"
File: /opt/mrtrix3/ANTs/build/ITKv5-install/include/ITK-5.0/itkCSVNumericObjectFileWriter.hxx
Line: 160
Description: itk::ERROR: CSVNumericObjectFileWriter(0x55e7cc81ad00): The file /home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2/stats_out/sub-r0073.1_in_0822.1/sub-r0073.1_in_0822.1_SME_LGM.csv cannot be opened for writing!
Reason: No such file or directory

[evelynd@m3t106 Test2]$

Thank you for your help

@gdevenyi
Copy link
Contributor

Let's confirm the target path exists and is writable

Please run
touch /home/evelynd/rb57_scratch/ENIGMA/ANALYSIS/PROCESSING/Lesion_Simulation/Final_Lesion_Simulation/ALL_SLF_SL_SVBG_FSOUT/0822.1/Stats_Testing/AAtest/Test2/stats_out/sub-r0073.1_in_0822.1/sub-r0073.1_in_0822.1_SME_LGM.csv

@EvPhD
Copy link
Author

EvPhD commented Apr 11, 2023

I ran the touch command without error and it produced an empty file in the correct location and with the correct file name.

I was thinking the issue must be to do with me not including an optional intensity image as when I was doing some testing originally, if I did include the path to an image for that optional intensity input then the intended output file was generated successfully in the correct target path.

@cookpa
Copy link
Member

cookpa commented Apr 11, 2023

@EvPhD your code is being formatted with markdown, prevent this by enclosing in triple backquotes

ls *anything*

I'm running ANTs Version: v2.4.2.post11-g066bebc on Mac. If I run

LabelGeometryMeasures 3 deepFlashT1w.nii.gz none stats.csv

I get

 file none does not exist . 

but the stats.csv file is produced. Do you not get the CSV file if you run like this?

@EvPhD
Copy link
Author

EvPhD commented Apr 12, 2023

Thankyou @cookpa yes I was able to get it running as you suggested above, and despite the terminal message that the file none does not exist, it did produce the CSV file output successuflly.

Before I close this issue, I was wondering if you could tell me where I could find the documentation that lists " none " as the default for this command. A colleague and I had both tried searching for information on this command prior to opening this issue and I just want to make sure I know where to look in the future.

Thank you for your help, it's much appreciated!

@cookpa
Copy link
Member

cookpa commented Apr 12, 2023

% LabelGeometryMeasures
Usage 1: LabelGeometryMeasures imageDimension labelImage [intensityImage=none] [csvFile]

Because the args are positional, you have to type "none" or it thinks the CSV file is actually the intensity image.

I should modify the code so that it doesn't give that error message if the intensity image is not there.

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

Successfully merging a pull request may close this issue.

3 participants