questions
questions > dcm2niix cannot find dicoms in files with wildcards within script
Sep 9, 2019 09:09 PM | sciencecasey
dcm2niix cannot find dicoms in files with wildcards within script
Hi there,
When I run from command line using variables and wildcards, the following executes perfectly:
```
cd ${sourcedir}
for direcs in *fmap*; do
#grab the directories within each functional task folders
dcm2niix -b y -z y -o ${outputdir}/sub-${subj}/ses-${session}/ -f ${subj}_%p_%s ${sourcedir}/*_${subj}_S${session}/dicom/Prisma*/201*****/FEU*/${direcs}
done
```
However, when this is put within a script, I receive the following error:
```
Processing subject 8001
Chris Rorden's dcm2niiX version v1.0.20190410 Clang10.0.0 (64-bit MacOS)
Error: Unable to find any DICOM images in /Users/casey/Desktop/working_folder/bids_structure_practice/GD_study/source/*_8001_S1/dicom/Prisma*/201*****/FEU*/{*mprage*} (or subfolders 5 deep)
```
It looks as though the wildcards are being taken as explicit input rather than used as wildcards. I have experimented with using quotations around each portion except the wildcards
```
"${sourcedir}/"*"_${subj}_S${session}/dicom/Prisma"*"/201"*****"/FEU"*"/${direcs}"
```
and it still doesn't work. I have modified the quotes a number of ways and it still will only find when copied and pasted directly in the terminal rather than being run as a script.
Thanks for your help
Casey
When I run from command line using variables and wildcards, the following executes perfectly:
```
cd ${sourcedir}
for direcs in *fmap*; do
#grab the directories within each functional task folders
dcm2niix -b y -z y -o ${outputdir}/sub-${subj}/ses-${session}/ -f ${subj}_%p_%s ${sourcedir}/*_${subj}_S${session}/dicom/Prisma*/201*****/FEU*/${direcs}
done
```
However, when this is put within a script, I receive the following error:
```
Processing subject 8001
Chris Rorden's dcm2niiX version v1.0.20190410 Clang10.0.0 (64-bit MacOS)
Error: Unable to find any DICOM images in /Users/casey/Desktop/working_folder/bids_structure_practice/GD_study/source/*_8001_S1/dicom/Prisma*/201*****/FEU*/{*mprage*} (or subfolders 5 deep)
```
It looks as though the wildcards are being taken as explicit input rather than used as wildcards. I have experimented with using quotations around each portion except the wildcards
```
"${sourcedir}/"*"_${subj}_S${session}/dicom/Prisma"*"/201"*****"/FEU"*"/${direcs}"
```
and it still doesn't work. I have modified the quotes a number of ways and it still will only find when copied and pasted directly in the terminal rather than being run as a script.
Thanks for your help
Casey
Threaded View
Title | Author | Date |
---|---|---|
sciencecasey | Sep 9, 2019 | |
Chris Rorden | Sep 10, 2019 | |