pyushkevich / greedy

Very fast greedy diffeomorphic registration code
GNU General Public License v3.0
66 stars 18 forks source link

Reslicing segmentations uses an insane amount of memory #46

Open jorgenriseth opened 2 months ago

jorgenriseth commented 2 months ago

Using

Greedy Version 1.3.0-alpha
  Release date:      Sep 28, 2022
  Compile date:      Aug 02, 2024
  GIT branch:        master
  GIT commit:        45cbc7c55c2833078e6fe13c8ec4c2c4bc9193e7
  GIT commit date:   2024-01-03 14:57:12 -0500

downloaded from https://sourceforge.net/projects/greedy-reg/files/, running on linux.

Tried running the following command:

greedy -d 3 -r \
    -rf fixed.nii.gz \
    -ri LABEL 0.2vox \
    -rm segmentation.nii.gz segmentation_resliced.nii.gz \
    -threads 1

where fixed.nii.gz is a T1-weighted 16-bit integer 368x512x512 image (0.5mm)^3 resolution, and segmentation.nii.gz is 32-bit integer 256x256x256 (1mm)^3 resolution labeled segmentation of the brain.

The memory consumption of the programs increases slowly and steadily over a 7-minute period, until it has used up all of my 32GB + 34 GB swap and is killed. Does the program actually need this much memory, or does it signify that some memory is not properly deleted?

Currently rerunning with valgrid to see if I can find any more infomation.

jorgenriseth commented 2 months ago

Does not seem like a memory leak, but it seems that the programs keeps requesting new memory of size 736MB (about correct for each image?), but does not release the old memory.

Have I done something stupid by not providing a transformation matrix ? I only want to resample to new resolution, as they should already be registered.

$valgrind --leak-check=yes greedy -d 3 -rf fixed.nii.gz -ri LABEL 0.2vox -rm segmentation.nii.gz segmentation_resliced.nii.gz -r

==120280== Memcheck, a memory error detector
==120280== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==120280== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==120280== Command: greedy -d 3 -rf fixed.nii.gz -ri LABEL 0.2vox -rm segmentation.nii.gz segmentation_resliced.nii.gz -r

==120280== 
Executing with the default number of threads: 16
==120280== Warning: set address range perms: large range [0xde2f040, 0x3be2f040) (undefined)
==120280== Warning: set address range perms: large range [0x3be30040, 0x52e30040) (undefined)
==120280== Warning: set address range perms: large range [0x654bd040, 0x7c4bd040) (undefined)
==120280== Warning: set address range perms: large range [0x654bd028, 0x7c4bd058) (noaccess)
==120280== Warning: set address range perms: large range [0x3be30028, 0x52e30058) (noaccess)
==120280== Warning: set address range perms: large range [0x59cbc040, 0xe3cbc040) (undefined)
==120280== Warning: set address range perms: large range [0xebcbe040, 0x119cbe040) (undefined)
==120280== Warning: set address range perms: large range [0x119cbf040, 0x147cbf040) (undefined)
==120280== Warning: set address range perms: large range [0x147cc0040, 0x175cc0040) (undefined)
==120280== Warning: set address range perms: large range [0x175cc1040, 0x1a3cc1040) (undefined)
==120280== Warning: set address range perms: large range [0x1a3cc2040, 0x1d1cc2040) (undefined)
==120280== Warning: set address range perms: large range [0x1d1cc3040, 0x1ffcc3040) (undefined)
==120280== Warning: set address range perms: large range [0x1ffcc4040, 0x22dcc4040) (undefined)
==120280== Warning: set address range perms: large range [0x22dcc5040, 0x25bcc5040) (undefined)
==120280== Warning: set address range perms: large range [0x25bcc6040, 0x289cc6040) (undefined)
==120280== Warning: set address range perms: large range [0x289cc7040, 0x2b7cc7040) (undefined)
==120280== Warning: set address range perms: large range [0x2b7cc8040, 0x2e5cc8040) (undefined)
==120280== Warning: set address range perms: large range [0x2e5cc9040, 0x313cc9040) (undefined)
==120280== Warning: set address range perms: large range [0x313cca040, 0x341cca040) (undefined)
==120280== Warning: set address range perms: large range [0x341ccb040, 0x36fccb040) (undefined)
==120280== Warning: set address range perms: large range [0x36fccc040, 0x39dccc040) (undefined)
==120280== Warning: set address range perms: large range [0x39dccd040, 0x3cbccd040) (undefined)
==120280== Warning: set address range perms: large range [0x3cbcce040, 0x3f9cce040) (undefined)
==120280== Warning: set address range perms: large range [0x3f9ccf040, 0x427ccf040) (undefined)
==120280== Warning: set address range perms: large range [0x427cd0040, 0x455cd0040) (undefined)
==120280== Warning: set address range perms: large range [0x455cd1040, 0x483cd1040) (undefined)
==120280== Warning: set address range perms: large range [0x483cd2040, 0x4b1cd2040) (undefined)
==120280== Warning: set address range perms: large range [0x4b1cd3040, 0x4dfcd3040) (undefined)
==120280== Warning: set address range perms: large range [0x4dfcd4040, 0x50dcd4040) (undefined)
==120280== Warning: set address range perms: large range [0x50dcd5040, 0x53bcd5040) (undefined)
==120280== Warning: set address range perms: large range [0x53bcd6040, 0x569cd6040) (undefined)
==120280== Warning: set address range perms: large range [0x569cd7040, 0x597cd7040) (undefined)
==120280== Warning: set address range perms: large range [0x597cd8040, 0x5c5cd8040) (undefined)
==120280== Warning: set address range perms: large range [0x5c5cd9040, 0x5f3cd9040) (undefined)
==120280== Warning: set address range perms: large range [0x5f3cda040, 0x621cda040) (undefined)
==120280== Warning: set address range perms: large range [0x621cdb040, 0x64fcdb040) (undefined)
==120280== Warning: set address range perms: large range [0x64fcdc040, 0x67dcdc040) (undefined)
==120280== Warning: set address range perms: large range [0x67dcdd040, 0x6abcdd040) (undefined)
==120280== Warning: set address range perms: large range [0x6abcde040, 0x6d9cde040) (undefined)
==120280== Warning: set address range perms: large range [0x6d9cdf040, 0x707cdf040) (undefined)
==120280== Warning: set address range perms: large range [0x707ce0040, 0x735ce0040) (undefined)
==120280== Warning: set address range perms: large range [0x735ce1040, 0x763ce1040) (undefined)
==120280== Warning: set address range perms: large range [0x763ce2040, 0x791ce2040) (undefined)
==120280== Warning: set address range perms: large range [0x791ce3040, 0x7bfce3040) (undefined)
==120280== Warning: set address range perms: large range [0x7bfce4040, 0x7edce4040) (undefined)
==120280== Warning: set address range perms: large range [0x7edce5040, 0x81bce5040) (undefined)
==120280== Warning: set address range perms: large range [0x81bce6040, 0x849ce6040) (undefined)
==120280== Warning: set address range perms: large range [0x849ce7040, 0x877ce7040) (undefined)
==120280== Warning: set address range perms: large range [0x877ce8040, 0x8a5ce8040) (undefined)
==120280== Warning: set address range perms: large range [0x8a5ce9040, 0x8d3ce9040) (undefined)
==120280== Warning: set address range perms: large range [0x8d3cea040, 0x901cea040) (undefined)
==120280== Warning: set address range perms: large range [0x901ceb040, 0x92fceb040) (undefined)
==120280== Warning: set address range perms: large range [0x92fcec040, 0x95dcec040) (undefined)
==120280== Warning: set address range perms: large range [0x95dced040, 0x98bced040) (undefined)
==120280== Warning: set address range perms: large range [0x98bcee040, 0x9b9cee040) (undefined)
==120280== Warning: set address range perms: large range [0x9b9cef040, 0x9e7cef040) (undefined)
==120280== Warning: set address range perms: large range [0x9e7cf0040, 0xa15cf0040) (undefined)
==120280== Warning: set address range perms: large range [0xa15cf1040, 0xa43cf1040) (undefined)
==120280== Warning: set address range perms: large range [0xa43cf2040, 0xa71cf2040) (undefined)
==120280== Warning: set address range perms: large range [0xa71cf3040, 0xa9fcf3040) (undefined)
==120280== Warning: set address range perms: large range [0xa9fcf4040, 0xacdcf4040) (undefined)
==120280== Warning: set address range perms: large range [0xacdcf5040, 0xafbcf5040) (undefined)
==120280== Warning: set address range perms: large range [0xafbcf6040, 0xb29cf6040) (undefined)
==120280== Warning: set address range perms: large range [0xb29cf7040, 0xb57cf7040) (undefined)
==120280== Warning: set address range perms: large range [0xb57cf8040, 0xb85cf8040) (undefined)
==120280== Warning: set address range perms: large range [0xb85cf9040, 0xbb3cf9040) (undefined)
==120280== Warning: set address range perms: large range [0xbb3cfa040, 0xbe1cfa040) (undefined)
==120280== Warning: set address range perms: large range [0xbe1cfb040, 0xc0fcfb040) (undefined)
Killed
jorgenriseth commented 2 months ago

Just to be sure, I attempted to apply affine registration to an image living in the same reference space as the segmentation, and then supply the affine transform matrix to the above command as well. Didn't make a difference.