Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional scripts needed #13

Closed
17 of 21 tasks
KrisThielemans opened this issue Jun 20, 2024 · 8 comments
Closed
17 of 21 tasks

Additional scripts needed #13

KrisThielemans opened this issue Jun 20, 2024 · 8 comments
Assignees
Labels
data documentation Improvements or additions to documentation enhancement New feature or request

Comments

@KrisThielemans
Copy link
Member

KrisThielemans commented Jun 20, 2024

  • create separate script SIRF_data_preparation/download_Siemens_mMR_NEMA_IQ.py to download/mMR_NEMA_IQ
    • download from zenodo (use zenodo_get)
    • copy mMR_template_span11.hs from sirf_data_path = os.path.join(examples_data_path('PET'), 'mMR')
  • create script SIRF_data_preparation/create_initial_images.py to run OSEM and kappa and save to disk(OSEM_image.hv, kappa.hv) takes as arguments
    • a folder-name where all the data is
    • an image-name for image size (for NEMA IQ will be the mumap as in the BSREM notebook)
  • NEMA_EQ specific: run script to generate ROIs
  • create script SIRF_data_preparation/create_converged_image.py to run BSREM for along time, see BSREM scripts to get converged images #16
    • compute metrics: CIL callback using TensorBoard

Prepared data (sinograms, OSEM_image, kappa, some plots) are at https://petric.tomography.stfc.ac.uk/data/

TODO

  • overall penalty weight is fixed to 1/700, might not be ok for future data-sets. Save the value somehow (e.g. simple text file), and read it from the script?, (done in BSREM scripts to get converged images #16 as optionally reading file)
  • Clean-up BSREM scripts https://github.com/SyneRBI/PETRIC/tree/BSREM_scripts - the 3 datasets are identical aside from the slice_number for the plot and the num_subsets (should be parameterised?), see BSREM scripts to get converged images #16
    • merge common functionailty into one file
    • use new callbacks & tensorboard logging
    • drop old-style interface of Algorithm (algo.x, algo.loss)?
  • End-to-end example
    • example_BSREM.ipynb
  • another example but also showing ISTA etc
    • example_ISTA.ipynb, main_ISTA.py
  • Update wiki to give instructions on notebook, getting data, create a status page (as we’ll need to give some more updates later). saying that from today -> added here https://github.com/SyneRBI/PETRIC/wiki/Recent-Updates
    • Registration is open
    • 3 example datasets are available (without VOIs), more to come
    • Docker build is edge (no release yet). Manual build is DEVEL_BUILD=ON.
    • Final threshold on metrics TBC
  • Insert "Edo's link" at https://github.com/SyneRBI/PETRIC/wiki
  • Make this repo public
  • Final consistency check
  • Announce
@KrisThielemans
Copy link
Member Author

KrisThielemans commented Jun 23, 2024

Current status on cdcl machine

download

python download_Siemens_mMR_NEMA_IQ.py 

creates

  • .../PETRIC/data/NEMA_IQ.zip
  • .../PETRIC/data/NEMA_IQ/ (unzipped)

create acquisition data etc

first edit data_utilities.py to set DATA_PATH (see #15), then

python prepare_mMR_NEMA_IQ_data.py

creates in dir that you set for DATA_PATH, which I set to ~/work/PETRIC (files should be in mMR/NEMA_IQ` subfolder of that)

20170809_NEMA_MUMAP_UCL.hv
20170809_NEMA_MUMAP_UCL.v
20170809_NEMA_UCL.n
additive_term.hs
additive_term.s
intermediate
md5sums.txt
mMR_template_span11.hs
mMR_template_span11.s
mMR_template_span11_small.hs
mMR_template_span11_small.s
multfactors.hs
multfactors.s
norm.n.hdr
prompts_f1g1d0b0.hs
prompts_f1g1d0b0.s
prompts.hs
prompts.s

There's far too many files there. (Edit: fixed in 871346b)

create OSEM

python create_initial_images.py ~/work/PETRIC/data -t 20170809_NEMA_MUMAP_UCL.hv

fails as filename conventions don't match. Fix: multfactors->mult_factors. (fixed in e6dd43a)

The OSEM_image output was nonsense however (min -2E35, max 0). This is due to UCL/STIR#1280

generate ROIs

find where SIRF-Contribs is from $PYTHONPATH (or later do from python)

cd ~/work/PETRIC/data
python ~/devel/install/sirf/contrib/NEMA/generate_nema_rois.py -i OSEM_image.hv

run BSREM

no script yet.

@KrisThielemans
Copy link
Member Author

KrisThielemans commented Jun 23, 2024

Using UCL/STIR#1463, initialisation is fine. However, OSEM gives a ring-artefact at the edge of the FOV currently, but when forcing image-size to xy-size 200

python ~/devel/PETRIC/SIRF_data_preparation/create_initial_images.py ~/devel/PETRIC/data -t 20170809_NEMA_MUMAP_UCL.hv --xy-size 200

it's fine. ROIs are also fine

im=STIR.ImageData('../data/OSEM_image.hv')
S6=STIR.ImageData('../data/S6.hv')
...
plt.imshow(im.as_array()[72,:,:],alpha=((S1+S3+S5+S6).as_array()[72,:,:]+1)/2)

image

@KrisThielemans
Copy link
Member Author

I've put a preliminary script for BSREM on the BSREM_scripts branch.

Left: 80 updates, middle: 660 updates, right: diff (at colour scale (-max,max)/20)
image

(im80-im660).abs().max()/im660.max()
np.float32(0.022381468)

@KrisThielemans
Copy link
Member Author

KrisThielemans commented Jun 23, 2024

NeuroLF with some corrections. I used exactly same settings, but BSREM subsets 16
image

Objective function
image
still a bit to go.

This took 1.5s per update on tomography.stfc

@KrisThielemans
Copy link
Member Author

KrisThielemans commented Jun 24, 2024

Vision 600 data with same settings, but 5 subsets. 80, 580 and 660 updates. (sorry, diff image failed)
image
image
image
about 6s per update

@KrisThielemans
Copy link
Member Author

For the record: data for mMR NEMA IQ was generated as follows:

cd ~/devel/PETRIC/SIRF_data_preparation
python download_Siemens_mMR_NEMA_IQ.py
python prepare_mMR_NEMA_IQ_data.py
DATADIR=~/devel/PETRIC/data/Siemens_mMR_NEMA_IQ/final
python create_initial_images.py $DATADIR -t ../processing/20170809_NEMA_MUMAP_UCL.hv --xy-size 200
pushd $DATADIR
python ~/devel/install/python/sirf/contrib/NEMA/generate_nema_rois.py -i OSEM_image.hv
rm *ahv *nii unregistered*
popd

However, I'll put the output in the shared location.

@KrisThielemans
Copy link
Member Author

Latest mMR results (slightly noisier data). 80, 580 and 660 updates and diff between the last 2 (at -max/20,max/20)
mMR_BSREM_obj_func
mMR_NEMA_BSREM_transverse_images

@KrisThielemans
Copy link
Member Author

all done with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants