-
Notifications
You must be signed in to change notification settings - Fork 441
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
add DICOMReader #2460
add DICOMReader #2460
Conversation
DICOM dataset was altered as is no longer a pancreas scan. Rather than explicitly name the type of scan, simply refer to it as a dicom stack, which is what is important, in case the data needs to change.
`pyvista/utilities/reader/get_reader` requires a file extension to work (it does not support folders). Since we would have to specify explicitly the files to be read from teh folder, we call the reader directly. However, we still support `get_reader` for reading a single `.dcm` file.
`pyvista/vtk-data` PR #5 was accepted. Pull dicom stack from here instead of temporary local directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Thanks for opening your first pull request in PyVista! 🚀 Please make sure you read (skim 😉) our Contributing Guide and abide by our Code of Conduct.
A few things to keep in mind:
- Remember to run the tests locally to make debugging issues easier.
- If you need help writing tests, take a look at the existing ones for inspiration. If you do not know where to start, let
@pyvista/developers
know and we will walk you through it. - All new features should be documented. It helps to write the docstrings for your functions/classes before writing the code. This will help you think about your code design and results in better code.
- No matter what, we are really grateful that you put in the effort to open this PR! ⭐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far.
See the notes regarding Style checking with pyvista. |
@adam-grant-hendry, please let me know if you need help cleaning up this PR. I might have time later this week. |
Yes, I was having trouble with ❯ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/python-jsonschema/check-jsonschema.
[INFO] Installing environment for https://github.com/python-jsonschema/check-jsonschema.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
codespell................................................................Passed
pydocstyle...............................................................Passed
mypy.....................................................................Passed
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
don't commit to branch...................................................Passed
Validate GitHub Workflows................................................Passed |
- Use `_download_and_read` for `dicom_stack` - Add volume plot in Examples docstrings - Update `DICOMReader` to accept files or folders - Remove redundant `dir_path` assignment in `examples.py` - Add test for valid mesh after loading single *.dcm file - Add test to `test_examples.py` - Update `check-jsonschema` to latest version
b597b64
to
f6b0c85
Compare
Yes please! That would be great. Currently tests are failing. One reason is vtk-data PR #10 with the zip file needs to be merged. Another is the docs:
It looks like I don't have a lot of GDAL dlls... win_build_docs_stderr.txt |
Codecov Report
@@ Coverage Diff @@
## main #2460 +/- ##
==========================================
- Coverage 93.73% 93.70% -0.03%
==========================================
Files 75 75
Lines 16052 16073 +21
==========================================
+ Hits 15046 15062 +16
- Misses 1006 1011 +5 |
1e97ace should take care of CI issues. Really pleased with this. Thanks for adding it @adam-grant-hendry, looks great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three very minor comments/suggestions to take or leave. The other is more important IMO.
Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling this one good to go, will wait 24H to merge for any final comments.
Congrats on your first PR @adam-grant-hendry! Keep'em coming. |
Perhaps I'm misunderstanding the changes/additions, but is it still the case that to actually read a DICOM directory you will need to specifically/manually import the DICOM reader sub-class and still cannot use Maybe the solution here is to add an optional flag kwarg to the |
Yes, to read a a stack of DICOM images, you must import the reader directly and pass it the folder (folders don't have file extensions). For a single DICOM, you could use the reader. This begs the question again regarding checking file extensions though...The entire reader is based solely off reading file extensions to determine the file type...I think we should update our docs to clearly state supported file types for readers. @akaszynski @adeak @MatthewFlamm @njneeteson I think we should keep #2471 open. If a file extension changes, the reader breaks. |
With respect to #2471 I just don't think it makes sense. As I commented in that issue, there's two possibilities: (1) You used The relevant extensions for each sub-class reader are also given in the docstring for each subclass. E.g. the doc page for
For this reason I don't really bother with EDIT: I dug into |
We need to separate a few things. Today You can use If the specific Reader has special requirements, we can override methods as needed. Sometimes vtk will throw warnings, but will still read non complying files OK |
Yeah I see where I am confused now. I had assumed that |
Agreed, and that's out of the scope of this (already long) PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this now, one last comment for consideration, but I think it is okay to merge as is.
Thanks @akaszynski !! I definitely will! I think next up I'd love to work on documentation and add some more examples! |
Totally fair. As long as things are documented so the end user doesn't go "What the heck?!", I like this approach (assume your user is smart). |
I think if someone was using pyvista and somehow was in a situation where |
I'm getting the following error from the docstring examples of
It looks as if it tried using a cached file (which I don't have) and not falling back to download. Any idea what's off? Or are we enforcing local caches for doc building and I have to run that function separately first? |
You'll have to clear out your cache. The issue is (and I should have addressed this), is we were improperly downloading a directory from github. The new example works now, but we need to flush the cache, or delete that invalid file. |
I see, so the cached version is the broken one, and what we have now works. This should probably only affect at most a few pyvista devs and nobody else, so this is fine then. Thanks @akaszynski! |
I've grepped for the "not found" filename in my repo (with
(I've also deleted Edit: that was it, thanks. |
Was going to respond, but been in JS land for the past two days and it's getting intense. Finally getting around to fixing |
Overview
Add
DICOMReader
(i.e._vtk.vtkDICOMImageReader
) toutilities/reader.py
. This is commit will assist in the bugfix commit for Issue #500 (NOTE: This originated on the oldpyvista/support
issue tracker).Details
DICOMReader
to standard dataset readersdownload_dicom_stack
toexamples/downloads.py
(added by @akaszynski)
Resolves #2467 as well.