Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive Scan visualization does not work #14

Open
fedorov opened this issue Jul 6, 2018 · 15 comments
Open

Interactive Scan visualization does not work #14

fedorov opened this issue Jul 6, 2018 · 15 comments

Comments

@fedorov
Copy link

fedorov commented Jul 6, 2018

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
Copy link
Owner

notmatthancock commented Jul 6, 2018

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
Copy link
Owner

This is referenced here: matplotlib/matplotlib#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
Copy link
Author

fedorov commented Jul 7, 2018

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 fedorov closed this as completed Jul 7, 2018
@notmatthancock
Copy link
Owner

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 notmatthancock reopened this Jul 7, 2018
@notmatthancock
Copy link
Owner

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
Copy link
Author

fedorov commented Jul 10, 2018

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

This didn't fix the issue on my end.

@notmatthancock
Copy link
Owner

Sorry, I meant %matplotlib notebook.

@fedorov
Copy link
Author

fedorov commented Nov 16, 2018

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

image

@fedorov
Copy link
Author

fedorov commented Nov 16, 2018

I figured this out by playing with this parameter: (huge thanks to matplotlib/matplotlib#4853 (comment))

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
Copy link
Owner

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
Copy link
Author

fedorov commented Nov 16, 2018

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

@notmatthancock
Copy link
Owner

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
Copy link
Author

fedorov commented Nov 16, 2018

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

@fedorov
Copy link
Author

fedorov commented Nov 16, 2018

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

@chinnujacob
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants