Thanks for the response!
It would help to know more about what the problems are with both approaches
At first, using os.system
worked well, however now the program complains that I am using conda as the application (I am not):
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
I’m not sure what I changed to bring about this error. The script continues to run notwithstanding this error, however if I use subprocess.run()
a la:
from subprocess import run
run('conda activate dcm2bids', shell = True)
run(f'dcm2bids --forceDcm2niix --clobber -d {args.dicom_dir} -c {dcm2bids}/config_{participant}.json -p {participant}', shell = True)
I run into this error:
subprocess.CalledProcessError: Command '['dcm2niix', '-b', 'y', '-ba', 'y', '-z', 'y', '-f', '%3s_%f_%p_%t', '-o', PosixPath('/home/darwin/fMRI_pp/SUDNU/tmp_dcm2bids/sub-001'), PosixPath('/home/darwin/fMRI_raw/SUDNU/001')]' returned non-zero exit status 7.
Using subprocess.check_call
gives this similar but slightly different error:
subprocess.CalledProcessError: Command '['./home/darwin/.local/bin/pybids-converter_helper.sh', '/home/darwin/fMRI_raw/SUDNU/001', '001']' returned non-zero exit status 127.
Where pybids-converter_helper.sh
looks like this:
. /home/darwin/miniconda3/etc/profile.d/conda.sh
conda activate dcm2bids
dcm2bids --forceDcm2niix --clobber -d $1 -c /home/darwin/dcm2bids/code/config_$2.json -p $2
conda deactivate
Running dcm2bids
in the same way as the codeblock in the OP does not give an error, however there is no output suggesting that the program actually converts the files:
WARNING:dcm2bids.version:Your using dcm2bids version 2.1.7
WARNING:dcm2bids.version:A new version exists : 2.1.9
WARNING:dcm2bids.version:Check https://github.com/unfmontreal/Dcm2Bids
WARNING:dcm2bids.dcm2niix:Previous dcm2niix directory output found:
WARNING:dcm2bids.dcm2niix:/home/darwin/Me/tmp_dcm2bids/sub-001
WARNING:dcm2bids.dcm2niix:'force' argument is set to True
WARNING:dcm2bids.dcm2niix:Cleaning the previous directory and running dcm2niix