Skip to content

Commit

Permalink
fix parsing for more generic StudyID tag in filename
Browse files Browse the repository at this point in the history
  • Loading branch information
akhanf committed Nov 18, 2024
1 parent 42b3a8d commit 477dd80
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tar2bids
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,20 @@ do
# x is studyID, for instance 1
if [[ $patient_etc == *_[0-9].*.* ]]; then
patient=${patient_etc%_[0-9].*.*}
fi

#PI_project_studydate_PatientName_StudyDate_xy.hashcode.tar
# StudyDate: for instance, 20190101
# xy is StudyID, for instance, 01
if [[ $patient_etc == *_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9].*.* ]]; then
elif [[ $patient_etc == *_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9].*.* ]]; then
patient=${patient_etc%_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9].*.*}

#PI_project_studydate_PatientName_StudyID.hashcode.tar
# x is studyID, for instance 1
else
studyid_etc=`echo $patient_etc | awk -F '_' '{print $NF}'`
patient=${patient_etc%_${studyid_etc}}
echo "studyid_etc: ${studyid_etc}"
echo "patient: ${patient}"
fi

# if $patient is empty, skip it.
Expand Down

0 comments on commit 477dd80

Please sign in to comment.