gschramm / pyapetnet

a CNN for anatomy-guided deconvolution and denoising of PET images
https://gschramm.github.io/pyapetnet/
MIT License
13 stars 4 forks source link

issue in thresholding #21

Open wtwang2001 opened 3 months ago

wtwang2001 commented 3 months ago

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

Hello,

I applied pyapetnet to 5-bed PET/MRI data. It finished successfully using model 190528_paper_bet_10_psf_mlem, but core dump using osem models.  Following is the message:

> Optimization terminated successfully.

> Current function value: -1.045613

> Iterations: 1

> Function evaluations: 42

> terminate called after throwing an instance of 'std::bad_alloc'

> what():  std::bad_alloc

> Aborted (core dumped)

 

After a couple of test runs, osem models work with 3-bed data. Then the resultant images were compared:

  | min | max | avg | std | X,Y, Z | filename -- | -- | -- | -- | -- | -- | -- 1 | 0.0 | 78688.0 | 1323.8 | 4910.4 | 447x230x577 | pyapetnet-psf-bet_bed123.nii 2 | -1445.8 | 110723.0 | 1104.1 | 4254.1 | 479x247x938 | pyapetnet-pdf-mlem_bed12345.nii

 

Questions:

1. it is a surprise that mlem had no problems in memory use, but osem led to core dump. Any thought?

2. there are negative voxel values in the resultant images from mlem model. Is it due to the mismatch of the PET recon method (for my PET images, osem) and the model (mlem)? 

3. It seems that pyapetnet reduces image matrix size by thresholding/extracting the input images. This leads to different x,y dimensions in 3- and 5-bed results (see comparison above). Further, half or more than half of the skull on top of the head was thresholded/removed. I wonder if there is a remedy/workaround for these? For example, a switch to choose thresholding value/method. Or a switch to skip the image thresholding/extracting step, and users have to threshold/extract images before applying pyapetnet.

 

Thank you.

gschramm commented 3 months ago

Hi,

  1. The core dump looks very strange. I suspect that it is due to the alignment performed via SITK. Can you rerun with the --no-coreg_inputs option to skip the co-registration?
  2. By default, the images are cropped the bounding box containing the "foreground" in the MR. You can use the --no-crop_mr option, to skip the cropping.
  3. Concerning the negative values: Whether the output is non-negative depends on the last layers of the model (ReLU vs PreLU). 190528_paper_bet_10_psf_mlem has no final ReLU (see here ), so the output can be negative. The 200824_mae... models have a final ReLU and their outputs are non-negative.
wtwang2001 commented 3 months ago

Thank you for the note.

  1. I tried osem model with --no_coreg, it skipped printing the messages about optimization and gave the error message:

    terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)

  2. it is nice to have the switch --no_crop. Definitely will use it.
  3. thank you. I will zero the negative values.
gschramm commented 3 months ago

To debug (1), you post: