ANTs icon indicating copy to clipboard operation
ANTs copied to clipboard

Unclosed brackets not detected in antsRegistration command line parameters

Open LeeReid1 opened this issue 1 year ago • 3 comments

Describe the problem

In antsRegistration, if using the -x argument, but missing off the final ], the command line will still run so long as no further registration stages follow. Nothing at all is printed to stdout as it runs, even if --verbose is set. It's not clear whether the flags that follow -x are ignored or not.

Expected behaviour would be an error message.

To Reproduce

When I've run this I've always provided absolute paths which is not reflected here for brevity:

antsRegistration --dimensionality 3 --initial-moving-transform [a.nii,b.nii,1] --winsorize-image-intensities [0.005,0.995] -o [_,c.nii,]  -t Rigid[0.1] -m CC[a.nii,b.nii.gz,1,0,Regular,0.5,1] -c [1000x500x200x200,1E-06,10] -s 8x4x2x1 -f 8x4x2x1 -x [f.nii,g.nii  --verbose --float 1 --use-histogram-matching 1 --collapse-output-transforms 1 --verbose 1

Note no ] after g.nii. If another stage follows the -x, then an error is correctly returned

System information

  • OS: Mac OS
  • OS version: 13.6.1
  • Type of system: Laptop
  • CPU architecture: ARM
  • Terminal: Bash

ANTs version information ANTs Version: 2.5.1.post24-g6c29d9d Compiled: Mar 13 2024 21:10:19 Compiled from source

Additional information Not the biggest bother but hard to catch as antsRegistration commands can get extremely long. I thought you'd like to be aware, but not an issue for me personally now I'm aware of it.

Thanks for the great tool.

LeeReid1 avatar Mar 24 '24 05:03 LeeReid1

Thanks for this report. This would be something I would attempt to fix at the parser level, as I expect it affects other programs as well.

cookpa avatar Mar 27 '24 13:03 cookpa

Just an FYI, if you add --help to the command line, the parsed values are posted as part of the help menu.

So, in the corrected case, with the right delimiter, the relevant option is

     -x, --masks [fixedImageMask,movingImageMask]
          Image masks to limit voxels considered by the metric. Two options are allowed 
          for mask specification: 1) Either the user specifies a single mask to be used 
          for all stages or 2) the user specifies a mask for each stage. With the latter 
          one can select to which stages masks are applied by supplying valid file names. 
          If the file does not exist, a mask will not be used for that stage. Note that we 
          handle the fixed and moving masks separately to enforce this constraint. 
          <VALUES>: [f.nii,g.nii]

     --float 
          Use 'float' instead of 'double' for computations. 
          <VALUES>: 1

vs. uncorrected:

     -x, --masks [fixedImageMask,movingImageMask]
          Image masks to limit voxels considered by the metric. Two options are allowed 
          for mask specification: 1) Either the user specifies a single mask to be used 
          for all stages or 2) the user specifies a mask for each stage. With the latter 
          one can select to which stages masks are applied by supplying valid file names. 
          If the file does not exist, a mask will not be used for that stage. Note that we 
          handle the fixed and moving masks separately to enforce this constraint. 
          <VALUES>: 1

     --float 
          Use 'float' instead of 'double' for computations. 

So you can see that the parser is most likely skipping over the bad option value and picking up the next one.

I don't have the time right now to prioritize this as it seems a highly infrequent incorrect usage case but I'll keep it in mind if I do get some time.

ntustison avatar Mar 27 '24 14:03 ntustison

Thanks @ntustison I agree this is not high priority.

I looked at this some more and there's nothing special happening that prevents terminal output, it's just that if you open a bracket and don't close it, the subsequent commands don't get parsed. If you put the --verbose before the unclosed bracket, it prints to the terminal. The only problem is that it prints All_Command_lines_OK, which isn't true,

cookpa avatar Apr 02 '24 18:04 cookpa