nipy / heudiconv

Flexible DICOM conversion into structured directory layouts
https://heudiconv.readthedocs.io
Other
234 stars 125 forks source link

Commandline --command option usage #707

Closed pbbaba closed 11 months ago

pbbaba commented 11 months ago

Summary

I am trying to use --command populate-intended-for with the command line tool. Also I have created the heuristic.py file and added the following in it - POPULATE_INTENDED_FOR_OPTS = { 'matching_parameters': ['ImagingVolume', 'Shims'], 'criterion': 'Closest' }

Following is the final command when I am running heudiconv using command line - docker run --rm -it \
-v /Users/pbaba1/Documents/Data/human/dicom/triotim/amayer/macip_20637:/data:ro \ -v /Users/pbaba1/Documents/BIDS:/output \ nipy/heudiconv:latest \ -d "data/{subject}/{session}//.dcm" \ -s M87100217 \ --command populate-intended-for -ss Study20160325at134915 \ -f /output/code/heuristic.py \ -c dcm2niix -b \ -o /output

However, when I run this it gives me the following error - INFO: Running heudiconv version 1.0.0 latest 1.0.0 Traceback (most recent call last): File "/opt/miniconda-py39_4.12.0/bin/heudiconv", line 8, in sys.exit(main()) File "/src/heudiconv/heudiconv/cli/run.py", line 30, in main workflow(kwargs) File "/src/heudiconv/heudiconv/main.py", line 361, in workflow raise ValueError("'command' given but 'files' is None") ValueError: 'command' given but 'files' is None**

Is there something that I am missing? I could not find proper documentation that describes the --command option's correct usage. Please guide on this.

yarikoptic commented 11 months ago

https://github.com/nipy/heudiconv/pull/708 should fix it. Meanwhile - just provide some bogus paths in --files -- they will be ignored

pbbaba commented 11 months ago

But --files and -d options do not go together, and I need to provide -d option (--dicom_dir_template). Any solution on working without providing --files option?

yarikoptic commented 11 months ago

the easiest: wait for that PR to be merged, then you can try/use nipy/heudiconv:master instead of :latest (which is the released version)

pbbaba commented 11 months ago

This led to the following error when I run the nipy/heudiconv:master-

INFO: Running heudiconv version 1.0.0.post2+gaa4c785 latest 1.0.0 Traceback (most recent call last): File "/opt/miniconda-py39_4.12.0/bin/heudiconv", line 8, in sys.exit(main()) File "/src/heudiconv/heudiconv/cli/run.py", line 30, in main workflow(**kwargs) File "/src/heudiconv/heudiconv/main.py", line 373, in workflow assert dicom_dir_template is None AssertionError

pbbaba commented 11 months ago

Also this is not working with the command line tool. While using the command line for this tool, it gives me the same error that it gave while I posted this issue. Is there any way this can be implemented for the command line heudiconv?

yarikoptic commented 11 months ago

not sure what you mean by "command line" as a separate thing from something else since heudiconv is a command line tool and there is no other way (e.g. GUI). What did you mean?

In your invocation now just remove -d "data/{subject}/{session}//.dcm" since it is not relevant when you specify --command populate-intended-for -- it would operate on already converted data.

pbbaba commented 11 months ago

The installation method has local, docker and singularity type. I am using the local one using pip install heudiconv. Please refer to the documentation provided here: https://heudiconv.readthedocs.io/en/latest/installation.html I am using the first option i.e. Local

I am trying to get the conversion process and populate intended for run in one go. If I do not pass -d option how will it determine from where should it use the files for bids conversion.

pbbaba commented 11 months ago

Please refer to the below command that I am using: heudiconv \ --dicom_dir_template 'staging/xxx/xxxx/xxx/{subject}/{session}/*/*/*.dcm' \ --subjects A0000000 \ --ses v1 \ --heuristic BIDS_output/code/heuristic.py \ --converter dcm2niix \ --bids \ --command populate-intended-for \ --outdir BIDS_output

yarikoptic commented 11 months ago

ok. for clarity of terminology as I see it -- it is either "native" or "containerized" executions. All of them are "local" to me (e.g. if you used reproman and made it execute on some server -- it would have been not local. containers are all running locally). In all cases all invocations remain done in "command line".

pbbaba commented 11 months ago

Is it also applicable for python package heudiconv? (I am using pip install heudiconv and not docker pull nipy/hueudiconv:master and `docker run ...)

So if I used POPULATE_INTENDED_FOR_OPTS = { 'matching_parameters': ['ImagingVolume', 'Shims'], 'criterion': 'Closest' } in my heuristic.py file and run the above mentioned command without adding --command populate-intended-for, I should see that 'IntendedFor' flag is there in the .json files?

FYI the below screenshot shows how my heuristic.py file looks like.

Screenshot 2023-09-28 at 1 39 41 PM
yarikoptic commented 11 months ago

So if I used POPULATE_INTENDED_FOR_OPTS = { 'matching_parameters': ['ImagingVolume', 'Shims'], 'criterion': 'Closest' } in my heuristic.py file and run the above mentioned command without adding --command populate-intended-for, I should see that 'IntendedFor' flag is there in the .json files?

yes, if 'ImagingVolume', and 'Shims' matched ... if you don't see -- check sizes and Shimming in the .json files you get

pbbaba commented 11 months ago

Okay great! Thanks for your help, I will run this.

github-actions[bot] commented 9 months ago

:rocket: Issue was released in v1.0.1 :rocket:

github-actions[bot] commented 9 months ago

:rocket: Issue was released in v1.0.1 :rocket: