diff --git a/SIRF_data_preparation/README.md b/SIRF_data_preparation/README.md index d17d37d..1666620 100644 --- a/SIRF_data_preparation/README.md +++ b/SIRF_data_preparation/README.md @@ -33,20 +33,20 @@ in `~/devel/PETRIC/data/` with `datasetname` following convention o PYTHONPATH=~/devel/PETRIC:$PYTHONPATH` ``` -1. Run initial [data_QC.py](data_QC) +1. Run initial [data_QC.py](data_QC.py) ``` python -m SIRF_data_preparation.data_QC ``` -2. Run [create_initial_images.py](create_initial_images). +2. Run [create_initial_images.py](create_initial_images.py). ``` python -m SIRF_data_preparation.create_initial_images --template_image= ``` where the template image is one of the given VOIs (it does not matter which one, as they should all have the same geometry). (If you need to create VOIs yourself, you can use `None` or the vendor image). 3. Edit `OSEM_image.hv` to add modality, radionuclide and duration info which got lost (copy from `prompts.hs`) 4. Edit [dataset_settings.py](dataset_settings.py) for subsets (used by our reference reconstructions only, not by participants). -5. Edit [../petric.py](petric.py) for slices to use for creating figures (`DATA_SLICES`). Note that `data_QC` outputs centre-of-mass of the VOIs, which can be helpful for this. -6. Run [data_QC](data_QC) which should now make more plots. Check VOI alignment etc. +5. Edit [petric.py](../petric.py) for slices to use for creating figures (`DATA_SLICES`). Note that `data_QC` outputs centre-of-mass of the VOIs, which can be helpful for this. +6. Run [data_QC.py](data_QC.py) which should now make more plots. Check VOI alignment etc. ``` python -m SIRF_data_preparation.data_QC --dataset= ``` @@ -58,5 +58,5 @@ PYTHONPATH=~/devel/PETRIC:$PYTHONPATH` ``` stir_math data//PETRIC/reference_image.hv output//iter_final.hv ``` -12. `rm output//*ahv`, check its `README.md` etc +12. `cd data/; rm -f *ahv info.txt warnings.txt`, check its `README.md` etc 13. Transfer to web-server diff --git a/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/README.md b/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/README.md new file mode 100644 index 0000000..8acaf9b --- /dev/null +++ b/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/README.md @@ -0,0 +1,8 @@ +# Siemens mMR NEMA IQ data (low counts) + +This relies on the "normal" count level processsing to be done first, specifically the download and the ROIs. + +Steps to follow: +1. `prepare_mMR_NEMA_IQ_data.py` +2. copy VOIs +3. further steps as [normal](../README.md#steps-to-follow-to-prepare-data) \ No newline at end of file diff --git a/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/__init__.py b/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/prepare_mMR_NEMA_IQ_data.py b/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/prepare_mMR_NEMA_IQ_data.py new file mode 100644 index 0000000..343d53c --- /dev/null +++ b/SIRF_data_preparation/Siemens_mMR_NEMA_IQ_lowcounts/prepare_mMR_NEMA_IQ_data.py @@ -0,0 +1,48 @@ +import argparse +import logging +import os + +from ..data_utilities import prepare_challenge_Siemens_data, the_data_path, the_orgdata_path + +this_directory = os.path.dirname(__file__) +repo_directory = os.path.dirname(this_directory) +challenge_data_path = os.path.join(repo_directory, 'data') + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='SyneRBI PETRIC Siemens mMR NEMA IQ data preparation script.') + + parser.add_argument('--log', type=str, default='warning') + parser.add_argument('--start', type=float, default=0) + parser.add_argument('--end', type=float, default=100) + parser.add_argument('--raw_data_path', type=str, default=None) + args = parser.parse_args() + + if args.log in ['debug', 'info', 'warning', 'error', 'critical']: + level = eval(f'logging.{args.log.upper()}') + logging.basicConfig(level=level) + logging.info(f"Setting logging level to {args.log.upper()}") + + start = args.start + end = args.end + + if args.raw_data_path is None: + data_path = the_orgdata_path('Siemens_mMR_NEMA_IQ', 'raw', 'NEMA_IQ') + else: + data_path = args.raw_data_path + + data_path = os.path.abspath(data_path) + logging.debug(f"Raw data path: {data_path}") + + intermediate_data_path = the_orgdata_path('Siemens_mMR_NEMA_IQ_lowcounts', 'processing') + challenge_data_path = the_data_path('Siemens_mMR_NEMA_IQ_lowcounts') + + os.makedirs(challenge_data_path, exist_ok=True) + os.chdir(challenge_data_path) + os.makedirs(intermediate_data_path, exist_ok=True) + + f_template = os.path.join(data_path, 'mMR_template_span11.hs') + + prepare_challenge_Siemens_data(data_path, challenge_data_path, intermediate_data_path, '20170809_NEMA_', + '60min_UCL.l.hdr', 'MUMAP_UCL.v', 'MUMAP_UCL.hv', 'UCL.n', 'norm.n.hdr', f_template, + 'prompts', 'mult_factors', 'additive_term', 'randoms', 'attenuation_factor', + 'attenuation_correction_factor', 'scatter', start, end) diff --git a/SIRF_data_preparation/create_initial_images.py b/SIRF_data_preparation/create_initial_images.py index 936aeb5..f8b13a2 100644 --- a/SIRF_data_preparation/create_initial_images.py +++ b/SIRF_data_preparation/create_initial_images.py @@ -82,9 +82,8 @@ def compute_kappa_image(obj_fun, initial_image): WARNING: Assumes the objective function has been set-up already """ - # This needs SIRF 3.7. If you don't have that yet, you should probably upgrade anyway! - Hessian_row_sum = obj_fun.multiply_with_Hessian(initial_image, initial_image.allocate(1)) - return (-1 * Hessian_row_sum).power(.5) + minus_Hessian_row_sum = -1 * obj_fun.multiply_with_Hessian(initial_image, initial_image.allocate(1)) + return minus_Hessian_row_sum.maximum(0).power(.5) def main(argv=None): diff --git a/SIRF_data_preparation/dataset_settings.py b/SIRF_data_preparation/dataset_settings.py index a59d52e..a0a9628 100644 --- a/SIRF_data_preparation/dataset_settings.py +++ b/SIRF_data_preparation/dataset_settings.py @@ -4,8 +4,8 @@ from petric import DATA_SLICES DATA_SUBSETS = { - 'Siemens_mMR_NEMA_IQ': 7, 'Siemens_mMR_ACR': 7, 'NeuroLF_Hoffman_Dataset': 16, 'Mediso_NEMA_IQ': 12, - 'Siemens_Vision600_thorax': 5} + 'Siemens_mMR_NEMA_IQ': 7, 'Siemens_mMR_NEMA_IQ_lowcounts': 7, 'Siemens_mMR_ACR': 7, 'NeuroLF_Hoffman_Dataset': 16, + 'Mediso_NEMA_IQ': 12, 'Siemens_Vision600_thorax': 5} @dataclass diff --git a/petric.py b/petric.py index e1b886a..e4a1e12 100755 --- a/petric.py +++ b/petric.py @@ -247,7 +247,8 @@ def get_image(fname): DATA_SLICES = { - 'Siemens_mMR_NEMA_IQ': {'transverse_slice': 72, 'coronal_slice': 109}, # 'sagittal_slice': 89 + 'Siemens_mMR_NEMA_IQ': {'transverse_slice': 72, 'coronal_slice': 109, 'sagittal_slice': 89} + 'Siemens_mMR_NEMA_IQ_lowcounts': {'transverse_slice': 72, 'coronal_slice': 109, 'sagittal_slice': 89}, 'Siemens_mMR_ACR': {'transverse_slice': 99}, 'NeuroLF_Hoffman_Dataset': {'transverse_slice': 72}, 'Mediso_NEMA_IQ': {'transverse_slice': 22, 'coronal_slice': 89, 'sagittal_slice': 66},