netstim / leaddbs

Lead-DBS is a MATLAB toolbox facilitating deep brain stimulation electrode localization and connectomic neuroimaging.
https://www.lead-dbs.org
Other
89 stars 97 forks source link

Memory consumption for MRI/CT image selection #1048

Open VoodooCode14 opened 1 year ago

VoodooCode14 commented 1 year ago

After importing many MRI/CT images, their concurrent display may eat up the entire memory. This should be avoided by either displaying at most n concurrent MRI/CT images or something similar.

The reason being: Users don't expect a program to occupy the entire memory which may result in everything from a crash of lead-DBS, to a crash of lead-DBS & other software, and potentially a crash of the entire system.

Difficult fix: Estimate the amount of memory required to visualize a picture and act accordingly. Simple fix: No more than n concurrent images. Which is reasonable, since nobody really requires to see 20 MRI scans concurrently to select the best one.

ningfei commented 1 year ago

Will try to optimize this for the new release. We may pre-filter the images before loading but I'm afraid it's not easy to find a general rule which could work for images from all different institutes.

I think the simple fix here is not actually a fix. If people don't go through the converted NIfTIs, how could they know which are the images they want? Especially when there are multiple pre-operative images available. And if they already know what they want, maybe it's much easier to only dump relevant DICOMs instead of everything from the patient. Once I even saw chest MRIs in the DICOM folder prepared for LeadDBS, which makes no sense.

VoodooCode14 commented 1 year ago

My mistake, looks like my description was imprecise. I was suggesting to only display one (or few) images at a time. You are right, people need to see all images eventually. However, if let's say the maximum number of concurrently displayed images was 5 (random number on my end), the moment one is closed, another one is free to pop up.

But yeah, finding a general rule on what to automatically decline, tricky tricky.

ningfei commented 1 year ago

maybe we can show static slices (screenshots) instead of full 3D images? images will be loaded only when people want to interact (click/scroll) in the viewer.

VoodooCode14 commented 1 year ago

Good idea for performance, however, it will be difficult to see DBS electrodes on these, especially if the target location is non standard (e.g. ANT or fornix).

Of course the decision is up to you, however, if you'd ask me what I prefer, I'd go with either a limited number of windows or a two-split window, on the left side the current nifti file (only a single one) and on the right side e.g. the currently selected pre-op MRI scan file. The latter ideally with build in buttons to skip new nifti files (left picture) and (right picture) the option to show different reference scans.