Skip to content

Commit

Permalink
Briefly disable PET, and modify error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Levitas committed Mar 13, 2024
1 parent 030645b commit 166dfc5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
43 changes: 21 additions & 22 deletions handler/find_img_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,27 @@ def find_img_data(dir):

find_img_data('.')


# PET
# TODO - These two lines take several seconds to complete, maybe can be sped up?
pet_folders = [str(folder) for folder in is_pet.pet_folder(Path(root).resolve())]
pet_folders = [os.path.relpath(x, root) for x in pet_folders if x != '']

pet_folders = [os.path.join('.', x) for x in pet_folders]
if pet_folders:
for pet_folder in pet_folders:
# See if we're dealing ECAT-formatted file(s)
ecats = [x for x in os.listdir(pet_folder) if x.endswith(tuple(['.v', '.v.gz']))]
if len(ecats):
for ecat in ecats:
if ecat not in pet_ecat_files_list:
pet_ecat_files_list.append(f'{pet_folder}/{ecat}')
# See if we're dealing with DICOM files
dcms = [
x for x in os.listdir(pet_folder)
if not x.endswith(tuple(['.nii', '.nii.gz', '.v', '.v.gz', '.json', '.tsv']))
]
if len(dcms) and pet_folder not in pet_dcm_dirs_list:
pet_dcm_dirs_list.append(pet_folder)
# # PET
# # TODO - Line below line take several seconds to complete, maybe can be sped up?
# pet_folders = [str(folder) for folder in is_pet.pet_folder(Path(root).resolve())]
# pet_folders = [os.path.relpath(x, root) for x in pet_folders if x != '']
# pet_folders = [os.path.join('.', x) for x in pet_folders]

# if pet_folders:
# for pet in pet_folders:
# # See if we're dealing ECAT-formatted file(s)
# ecats = [x for x in os.listdir(pet) if x.endswith(tuple(['.v', '.v.gz']))]
# if len(ecats):
# for ecat in ecats:
# if ecat not in pet_ecat_files_list:
# pet_ecat_files_list.append(f'{pet}/{ecat}')
# # See if we're dealing with DICOM files
# dcms = [
# x for x in os.listdir(pet)
# if not x.endswith(tuple(['.nii', '.nii.gz', '.v', '.v.gz', '.json', '.tsv']))
# ]
# if len(dcms) and pet not in pet_dcm_dirs_list:
# pet_dcm_dirs_list.append(pet)

# MEG
MEG_extensions = ['*.ds', '*.fif', '*.sqd', '*.con', '*.raw', '*.ave', '*.mrk', '*.kdf', '*.mhd', '*.trg', '*.chn', '*.dat']
Expand Down
20 changes: 10 additions & 10 deletions handler/preprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ else
# # remove error message(s) about not finding any DICOMs in folder
line_nums=$(grep -n 'Error: Unable to find any DICOM images' $root/dcm2niix_error | cut -d: -f1)

for line_num in ${line_nums[*]}
do
sed -i "$((line_num-1)), $((line_num+1))d" $root/dcm2niix_error
done
# for line_num in ${line_nums[*]}
# do
# sed -i "$((line_num-1)), $((line_num+1))d" $root/dcm2niix_error
# done
fi

# Check for pet2bids errors
Expand All @@ -229,10 +229,10 @@ else
# # remove error message(s) about not finding any DICOMs in folder
line_nums=$(grep -n 'Error: Unable to find any DICOM images' $root/pet2bids_error | cut -d: -f1)

for line_num in ${line_nums[*]}
do
sed -i "$((line_num-1)), $((line_num+1))d" $root/pet2bids_error
done
# for line_num in ${line_nums[*]}
# do
# sed -i "$((line_num-1)), $((line_num+1))d" $root/pet2bids_error
# done
fi

# Add all transformed data (e.g. NIfTI or MEG formats) to the list file
Expand All @@ -255,8 +255,8 @@ else

echo ""
echo "Error: Could not find any MRI, PET, or MEG imaging files in upload."
echo "Please click the Debug section below and select Download ${err_file}"
echo "We recommend reaching out to the dcm2niix team for assistance: https://github.com/rordenlab/dcm2niix/issues"
echo "Please click the Debug (Download) section below and select the ${err_file} file."
echo "Please reach out to the ezBIDS team for further assistance: https://github.com/brainlife/ezbids/issues"
exit 1
fi

Expand Down

0 comments on commit 166dfc5

Please sign in to comment.