notmatthancock / pylidc

An object relational mapping for the LIDC dataset using sqlalchemy.
https://pylidc.github.io
Other
104 stars 42 forks source link

Interactive Scan visualization does not work #14

Open fedorov opened 6 years ago

fedorov commented 6 years ago

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

notmatthancock commented 6 years ago

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 commented 6 years ago

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?

fedorov commented 6 years ago

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!

notmatthancock commented 6 years ago

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 commented 6 years ago

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.

fedorov commented 6 years ago

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

This didn't fix the issue on my end.

notmatthancock commented 6 years ago

Sorry, I meant %matplotlib notebook.

fedorov commented 6 years ago

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

image

fedorov commented 6 years ago

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!

notmatthancock commented 6 years ago

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.

fedorov commented 6 years ago

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

notmatthancock commented 6 years ago

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.

fedorov commented 6 years ago

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

fedorov commented 6 years ago

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

chinnujacob commented 5 years ago

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?