pylidc icon indicating copy to clipboard operation
pylidc copied to clipboard

Interactive Scan visualization does not work

Open fedorov opened this issue 7 years ago • 15 comments
trafficstars

Following the instructions and example here: https://pylidc.github.io/tuts/scan.html#scan-visualization, the result is a static image, not interactive visualization.

See demo of the actual behavior here: https://www.screencast.com/t/kSNVqyRP1Rt

fedorov avatar Jul 06 '18 20:07 fedorov

Hmm. I had this same issue with volume_viewer in the utils module. Unfortunately, I can't remember the fix at the moment ... something to do with weak references ...

notmatthancock avatar Jul 06 '18 22:07 notmatthancock

This is referenced here: https://github.com/matplotlib/matplotlib/issues/3105/ I'm not sure how to resolve it in the pylidc context. I will have to look into it more.

It is difficult to debug on my since it seems to happen only 1 in 10 times I run the code. Is the slider non-responsive every time you try to use the visualize routine? How about Annotation.visualize_in_scan? Is the behavior the same there for you?

notmatthancock avatar Jul 07 '18 00:07 notmatthancock

It looks like it consistently does not work in jupyter notebook, but maybe that is expected. It does work when running from a standalone script. Thanks!

fedorov avatar Jul 07 '18 02:07 fedorov

I'm going to reopen this because I've run into this issue a few times in ipython. I haven't used notebooks in quite a while, so I'm not sure how well matplotlib widgets work there. Anyhow, regardless of ipython or jupyter, this is definitely an annoyance because interactive environments are precisely those where one would like to use the interactive viewers.

notmatthancock avatar Jul 07 '18 02:07 notmatthancock

Starting the jupyter notebook with %matplotlib inline recovers the interactivity of the slider. However, the generated figure is not automatically resized to fit the context of the cell, and is much too large on my machine.

notmatthancock avatar Jul 10 '18 02:07 notmatthancock

Starting the jupyter notebook with %matplotlib inline recovers the interactivity of the slider.

This didn't fix the issue on my end.

fedorov avatar Jul 10 '18 17:07 fedorov

Sorry, I meant %matplotlib notebook.

notmatthancock avatar Jul 11 '18 00:07 notmatthancock

Thanks - that worked - it is interactive now, but does not scale properly

image

fedorov avatar Nov 16 '18 22:11 fedorov

I figured this out by playing with this parameter: (huge thanks to https://github.com/matplotlib/matplotlib/issues/4853#issuecomment-220853279)

import matplotlib as mpl
mpl.rcParams['figure.dpi'] = 50

I guess it has something to do that I have a very big (and rather antique!) display on my desk!

fedorov avatar Nov 16 '18 22:11 fedorov

I guess it has something to do that I have a very big (and rather antique!) display on my desk!

I don't think so. The default GUI is definitely not created in a smart way, and essentially relies on the window being scaled automatically when not in a notebook.

notmatthancock avatar Nov 16 '18 22:11 notmatthancock

This is in the notebook, I used your directive you suggested earlier: %matplotlib notebook.

fedorov avatar Nov 16 '18 22:11 fedorov

I'm saying that in the non-notebook setting, we can play fast and loose with making things too big since the window manager automatically rescales things to fit in the available screen space. We don't have this luxury in the notebook view, which is why it appears so big, but I'm glad that setting the DPI provides a work-around.

notmatthancock avatar Nov 16 '18 22:11 notmatthancock

I see. I have not tried to run it in non-notebook setting.

fedorov avatar Nov 16 '18 22:11 fedorov

Ah, works SO much better outside of the notebook! Thanks!

fedorov avatar Nov 16 '18 23:11 fedorov

i am a beginner in LIDC dataset. Could u please tell me how to specify path in configuration file.i tried using the tutorial given.But i got the following error. vol = scan.to_volume() 2 print(vol.shape) 3 4 print("%.2f, %.2f" % (vol.mean(), vol.std()))

~/anaconda3/lib/python3.6/site-packages/pylidc/Scan.py in to_volume(self, verbose) 637 Return the scan as a 3D numpy array volume. 638 """ --> 639 images = self.load_all_dicom_images(verbose=verbose) 640 641 volume = np.zeros((512,512,len(images)))

~/anaconda3/lib/python3.6/site-packages/pylidc/Scan.py in load_all_dicom_images(self, verbose) 286 if verbose: print("Loading dicom files ... This may take a moment.") 287 --> 288 path = self.get_path_to_dicom_files() 289 fnames = [fname for fname in os.listdir(path) 290 if fname.endswith('.dcm')]

~/anaconda3/lib/python3.6/site-packages/pylidc/Scan.py in get_path_to_dicom_files(self) 213 "specified the path option in the configuration " 214 "file {}?") --> 215 raise RuntimeError(msg.format(_get_config_file())) 216 217 base = os.path.join(dicompath, self.patient_id)

RuntimeError: Could not establish path to dicom files. Have you specified the path option in the configuration file /home/user/.pylidcrc?

chinnujacob avatar Feb 15 '19 10:02 chinnujacob