diff --git a/docs/dataset_preprocessing.md b/docs/dataset_preprocessing.md index 1185ec1..70549fa 100644 --- a/docs/dataset_preprocessing.md +++ b/docs/dataset_preprocessing.md @@ -4,11 +4,16 @@ ### Single Map -To calculate an ADC map, run +To calculate an ADC map, run: !!! note "" - pd-dwi-preprocessing adc -dwi_folder -b + pd-dwi-preprocessing adc -dwi_data -b -### Batch +### Batch Mode -TBD \ No newline at end of file +To calculate an ADC map for a large number of folders, run: + +!!! note "" + pd-dwi-preprocessing adc -dwi_data -b + +The input file for ADC batch processing is a CSV file where the first row contains a header (skipped in processing), and each subsequent row represents a path for a DWI acquisition folder. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5824e31..99a1a00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pd-dwi" -version = "1.1.0" +version = "1.1.1" description = "Physiologically-Decomposed Diffusion-Weighted MRI machine-learning model for predicting response to neoadjuvant chemotherapy in invasive breast cancer" authors = [ "Maya Gilad " diff --git a/src/pd_dwi/scripts/adc_preprocess_command.py b/src/pd_dwi/scripts/adc_preprocess_command.py index 176a02f..7457b34 100644 --- a/src/pd_dwi/scripts/adc_preprocess_command.py +++ b/src/pd_dwi/scripts/adc_preprocess_command.py @@ -1,15 +1,24 @@ +import os.path + from pd_dwi.preprocessing.adc import calculate_adc def adc_preprocess(args): - dwi_folder_path = args.dwi_folder + input_data = args.dwi_data b_values = args.b - calculate_adc(dwi_folder_path, set(b_values), dwi_folder_path) + if os.path.isdir(input_data): + calculate_adc(input_data, set(b_values), input_data) + else: + with open(input_data, mode='r') as f: + # Skip first line + f.readline() + for dwi_folder in f.readlines(): + calculate_adc(dwi_folder, set(b_values), dwi_folder) def add_adc_parser(parser) -> None: - parser.add_argument('-dwi_folder', type=str, required=True, help="Path for DWI acquisition folder") + parser.add_argument('-dwi_data', type=str, required=True, help="Path for DWI acquisition folder or input file listing DWI folders") parser.add_argument('-b', type=int, nargs='+', required=True, help="B-values to use for ADC calculation") parser.set_defaults(func=adc_preprocess)