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

Cropping with SIRF <= v2.1.0 #52

Closed
rijobro opened this issue Jun 4, 2020 · 0 comments
Closed

Cropping with SIRF <= v2.1.0 #52

rijobro opened this issue Jun 4, 2020 · 0 comments

Comments

@rijobro
Copy link
Contributor

rijobro commented Jun 4, 2020

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!

@rijobro rijobro closed this as completed Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant