[SyneRBI/SIRF-Exercises] Cropping with SIRF <= v2.1.0 (#52)

0 views
Skip to first unread message

Richard Brown

unread,
Jun 4, 2020, 8:28:37 AM6/4/20
to SyneRBI/SIRF-Exercises, Subscribed

The following was in this notebook as a workaround for older versions of SIRF: https://github.com/SyneRBI/SIRF-Exercises/blob/master/notebooks/Synergistic/BrainWeb.ipynb

I don't really want it in that notebook, so I'll move it here, close the issue and point that notebook to here.

Cropping with SIRF <= v2.1.0

zoom_image and move_to_scanner_centre didn't exist prior to SIRF v2.1.0. If your version is older, you can use the STIR executable and a bit of bash. To be able to use stir executables, make sure they're enabled. This is system dependent, but might look something like this:

cd ~/devel/buildVM
cmake . -DSTIR_BUILD_EXECUTABLES:BOOL=ON
make

Now you should be able to replace:

im = im.zoom_image(size=(-1,150,150),offset_in_mm=(0,25,25))
im = im.move_to_scanner_centre(templ_sino)
im.write(fname + "_small.hv")
return im

with:

small_fname = fname + "_small.hv"
!zoom_image {small_fname} {fname}.hv 150 1 25 25
!sed -r -i 's/.*first pixel offset \(mm\).*//' {small_fname}
return pet.ImageData(small_fname)

You'll have to do something similar when it comes to misalignment. You'll have to switch the following:

resampled = resampler.get_output()
misaligned_image = resampled.move_to_scanner_centre(templ_sino)
return misaligned_image

with the following:

resampled = resampler.get_output().write("tmp_resampled")
!sed -i '/first pixel offset (mm)/d' tmp_resampled.hv
misaligned_image = pet.ImageData("tmp_resampled.hv")
!rm ./tmp_resampled.*
return misaligned_image

sed is system dependent, so I give no promise that this will work. But give it a go if necessary!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Richard Brown

unread,
Jun 4, 2020, 8:28:42 AM6/4/20
to SyneRBI/SIRF-Exercises, Subscribed

Closed #52.

Reply all
Reply to author
Forward
0 new messages