Skip to content

Commit 06749c9

Browse files
committed
fix: glob + quote paths in chexpert runner too
1 parent e453d06 commit 06749c9

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

mimic-iv-cxr/txt/chexpert/run_chexpert_on_files.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ fi
2222
sleep 2
2323

2424
# loop through each .csv file in the section folder
25-
for fn in `ls $REPORT_PATH`; do
26-
echo `date`: $fn
27-
fn_stem=`echo $fn | cut -d. -f 1`
25+
for fn_path in "$REPORT_PATH"/*.csv; do
26+
[ -f "$fn_path" ] || continue
27+
fn=$(basename "$fn_path")
28+
echo "$(date): $fn"
29+
fn_stem=${fn%.csv}
2830
# run chexpert - must be run from chexpert folder
29-
python $CHEXPERT_PATH/label.py --verbose --reports_path $REPORT_PATH/$fn --output_path ${fn_stem}_labeled.csv --mention_phrases_dir $CHEXPERT_PATH/phrases/mention --unmention_phrases_dir $CHEXPERT_PATH/phrases/unmention --pre_negation_uncertainty_path $CHEXPERT_PATH/patterns/pre_negation_uncertainty.txt --negation_path $CHEXPERT_PATH/patterns/negation.txt --post_negation_uncertainty_path $CHEXPERT_PATH/patterns/post_negation_uncertainty.txt
30-
echo `date`: done!
31+
python "$CHEXPERT_PATH/label.py" --verbose \
32+
--reports_path "$fn_path" \
33+
--output_path "${fn_stem}_labeled.csv" \
34+
--mention_phrases_dir "$CHEXPERT_PATH/phrases/mention" \
35+
--unmention_phrases_dir "$CHEXPERT_PATH/phrases/unmention" \
36+
--pre_negation_uncertainty_path "$CHEXPERT_PATH/patterns/pre_negation_uncertainty.txt" \
37+
--negation_path "$CHEXPERT_PATH/patterns/negation.txt" \
38+
--post_negation_uncertainty_path "$CHEXPERT_PATH/patterns/post_negation_uncertainty.txt"
39+
echo "$(date): done!"
3140
echo ''
32-
done
41+
done

mimic-iv-cxr/txt/negbio/run_negbio.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ do
4646
# all intermediate files will be saved in this folder
4747
export OUTPUT_DIR=${INPUT_FILE::-4}
4848

49-
echo $OUTPUT_DIR - running NegBio..
49+
echo "$OUTPUT_DIR - running NegBio.."
5050
python "$NEGBIO_PATH/negbio/negbio_csv2bioc.py" --output "$OUTPUT_DIR/report" "$INPUT_FILE"
5151
python $NEGBIO_PATH/negbio/negbio_pipeline.py section_split --pattern $NEGBIO_PATH/patterns/section_titles_cxr8.txt --output $OUTPUT_DIR/sections $OUTPUT_DIR/report/* --workers=6
5252
python $NEGBIO_PATH/negbio/negbio_pipeline.py ssplit --output $OUTPUT_DIR/ssplit $OUTPUT_DIR/sections/* --workers=6
@@ -57,7 +57,7 @@ do
5757

5858
# ultimate filename we save the labels to
5959
export OUTPUT_LABELS=$OUTPUT_DIR/${fn::-4}_labels.csv
60-
python $NEGBIO_PATH/negbio/ext/chexpert_collect_labels.py --phrases_file $NEGBIO_PATH/patterns/chexpert_phrases.yml --output $OUTPUT_LABELS $OUTPUT_DIR/neg/*
60+
python "$NEGBIO_PATH/negbio/ext/chexpert_collect_labels.py" --phrases_file "$NEGBIO_PATH/patterns/chexpert_phrases.yml" --output "$OUTPUT_LABELS" "$OUTPUT_DIR"/neg/*
6161
fi
6262
done
6363
echo "Done looping through files."

0 commit comments

Comments
 (0)