Skip to content

Commit

Permalink
Merge pull request #8 from sct-pipeline/jv/fix_folder_creation
Browse files Browse the repository at this point in the history
Fix folder creation
  • Loading branch information
valosekj authored Dec 9, 2024
2 parents a2ceeb6 + 9f5b632 commit 16222fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions file_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ def write_participants_tsv(bids_folder, participant_id, session_id, source_id, a
])
logging.info(f"Info: Added entry for {participant_id}/{session_id} to participants.tsv")

def print_script_finished():
"""
Print a message that the script has finished successfully.
"""
logging.info(100 * "-")
logging.info(f'{os.path.abspath(__file__)} finished successfully.')
logging.info(100 * "-")


def main():
"""
Expand Down Expand Up @@ -403,6 +411,7 @@ def main():
break
elif user_input in ['n', 'no']:
logging.info("Skipping the DICOM to NIfTI conversion.")
print_script_finished()
return False
else:
logging.info("Warning: Invalid input. Please enter 'yes' or 'no'.")
Expand Down Expand Up @@ -458,9 +467,7 @@ def main():
source_id = os.path.basename(os.path.normpath(dicom_folder))
write_participants_tsv(bids_folder, participant_id, session_id, source_id, args.age, args.sex)

logging.info(100 * "-")
logging.info(f'{os.path.abspath(__file__)} finished successfully.')
logging.info(100 * "-")
print_script_finished()


if __name__ == "__main__":
Expand Down
5 changes: 4 additions & 1 deletion process_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ create_results_folder_and_copy_images()
# Go to folder where data will be copied and processed
cd "$results_folder"
# Copy source images
cp -r "$bids_folder"/"$participant_id"/"$session_id" .
mkdir -p "$participant_id"
cp -r "$bids_folder/$participant_id/$session_id" "$participant_id/"
# Note: We need to create "$participant_id" first, to preserve the directory structure (e.g., sub-001/ses-01) when
# copying the files. Otherwise, only ses-01 folder would be copied to the results folder.
}

# Inspiration: https://github.com/spinalcordtoolbox/sct_tutorial_data/blob/master/multi_subject/process_data.sh#L66-L89
Expand Down

0 comments on commit 16222fa

Please sign in to comment.