Skip to content

Commit

Permalink
Added batch mode (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
giladmaya authored Jun 29, 2024
1 parent 8042432 commit b470550
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
13 changes: 9 additions & 4 deletions docs/dataset_preprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path/to/DWI/data\> -b <list/of/b/values\>
pd-dwi-preprocessing adc -dwi_data <path/to/DWI/data\> -b <list/of/b/values\>

### Batch
### Batch Mode

TBD
To calculate an ADC map for a large number of folders, run:

!!! note ""
pd-dwi-preprocessing adc -dwi_data <path/to/input/file\> -b <list/of/b/values\>

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.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
Expand Down
15 changes: 12 additions & 3 deletions src/pd_dwi/scripts/adc_preprocess_command.py
Original file line number Diff line number Diff line change
@@ -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)

1 comment on commit b470550

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
pd_dwi
   __init__.py20100% 
   dataset.py463230%12, 15–18, 20–22, 24, 26–27, 29, 31–32, 34–37, 39–43, 45, 47–49, 56, 59, 62, 66, 69
   model.py803753%56, 58–60, 62–63, 66, 68–70, 72–73, 77–78, 80–82, 84–85, 87–88, 90, 92–94, 100–111
   training_utils.py53492%27–28, 60, 84
pd_dwi/config
   __init__.py00100% 
   config.py71198%100
   utils.py11190%15
pd_dwi/feature_selection
   __init__.py00100% 
   select_k_best.py60100% 
pd_dwi/models
   __init__.py12466%14–16, 18
pd_dwi/preprocessing
   __init__.py00100% 
   adc.py855041%15, 17–18, 20–21, 23–26, 28, 84–85, 87–90, 92, 95, 98–100, 103, 105, 107, 110–112, 114–115, 117–118, 130–131, 133, 135–137, 139–140, 142–146, 148, 161–162, 164–165, 168
   column_transformer.py10460%14–15, 18, 20
pd_dwi/preprocessing/transformers
   __init__.py00100% 
   hormone_receptor_encoder.py19952%16–17, 19, 22–24, 26, 29, 32
   radiomics_encoder.py692859%40, 43, 55–56, 58, 61, 63–64, 66, 68, 71, 74, 77–82, 84–85, 87, 90, 93–98
   sbr_grade_encoder.py21957%18–19, 22, 24, 27–28, 30, 33, 36
pd_dwi/scripts
   __init__.py00100% 
   adc_preprocess_command.py151126%7–8, 10–11, 13, 15–17, 21–22, 24
   cli.py24675%25, 27, 29, 31–32, 36
   list_command.py90100% 
   predict_command.py251444%9–10, 12–13, 15, 17–19, 21, 23–24, 26–27, 29
   score_command.py8275%5–6
   train_command.py10370%5–7
pd_dwi/utils
   __init__.py00100% 
   dcm_utils.py211528%10–12, 14, 21, 23–26, 28, 30–32, 34, 39
TOTAL59723061% 

Please sign in to comment.