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

Format dicom #52

Merged
merged 8 commits into from
May 6, 2024
Merged

Format dicom #52

merged 8 commits into from
May 6, 2024

Conversation

tcpan
Copy link
Collaborator

@tcpan tcpan commented May 4, 2024

Updated read and write. Better standard compliance for write. Reading now allows random data access.

@tompollard
Copy link
Contributor

Thanks @tcpan. I think we should go ahead and merge, but we will have to do some restructuring afterwards because our current framework expects each module in the formats folder to represent a separate format.

@bemoody @briangow my suggestion would be either:

  1. allowing formats to include utilities in a subfolder within formats. e.g.

    waveform_benchmark/formats/dicom.py -> leave in current location

    waveform_benchmark/formats/dcm_rand_access.py -> waveform_benchmark/formats/dicom/rand_access.py

    waveform_benchmark/formats/dcm_waveform_reader.py -> waveform_benchmark/formats/dicom/waveform_reader.py

    waveform_benchmark/formats/dcm_waveform_writer.py ->
    waveform_benchmark/formats/dicom/waveform_writer.py

  2. Store rand_access.py, waveform_reader.py, waveform_writer.py in a separate repository, which is then added as a dependency here. This might make sense if we consider the modules to be implementing the format, rather than just applying it.

Copy link
Collaborator

@briangow briangow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tcpan , thanks so much for this - preparing the DICOM format for benchmarking clearly took a lot of work!

I've left a couple of comments in the code. One other thought is that it might be cleaner to move the dcm_* files under a separate folder (perhaps formats/dcm_utils/dcm_*) such that the only files at the formats/ level are the ones that get called for benchmarking. This is completely up to you though, no worries if you prefer to leave them where they are. @tompollard beat me to this suggestion above.

# import json

# ======== organize the waveform chunks (tested)
print("INPUT pleth", waveforms['Pleth'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this line should get commented out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

# MultichannelRespiratoryWaveform: RESP, >1, , unconstrained, DCID 3005 “Respiration Waveform” , SS/SL
#

CHANNEL_TO_DICOM_IOD = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add the other channel types from the proposed suite of waveforms for benchmarking? See Waveform suite characterization here: #11 (comment) .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this needs to be updated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tcpan , I've started an issue to track this: #53

@tcpan
Copy link
Collaborator Author

tcpan commented May 5, 2024 via email

@briangow
Copy link
Collaborator

briangow commented May 5, 2024

Hi, Brian, sorry for the delay. Was working on house stuff all day. Will do re subfolder. Is formats the right place to put that?

@tcpan , it's up to you. If you feel that these files are useful beyond this repository perhaps they deserve a dedicated place as @tompollard suggested in this 2nd thought on the topic. It would probably make sense to create a general utils module in this repository at some point. If you prefer that option feel free to set it up or let me know and I'd be happy to do so. As far as I'm concerned, having them in a subfolder under formats/ is also fine.

tcpan added 3 commits May 6, 2024 10:39
…sing of specified tags only. FIX: input chunks of the same channels were recorded as separate channels in the channel definition. ENH: optimization with deferred dataset reading, and avoid using pydicom's reading functions where possible. ENH: moved support files to format/dcm_utils
@tcpan
Copy link
Collaborator Author

tcpan commented May 6, 2024

I have checked in some updates, with some fixes and some new tests for different chunking strategy (likely not to make a huge difference). Note that to get the channel metadata, each file is opened and scanned. A more efficient way to do this would be to add the channel metadata as a private tag on the DICOMDIR file. This would still be standards compliant, but I have not implemented this.

@briangow
Copy link
Collaborator

briangow commented May 6, 2024

Thanks @tcpan !

@briangow briangow merged commit 51f49b1 into main May 6, 2024
1 of 2 checks passed
@tompollard
Copy link
Contributor

Hi, Brian, sorry for the delay. Was working on house stuff all day. Will do re subfolder. Is formats the right place to put that?

@tcpan , it's up to you. If you feel that these files are useful beyond this repository perhaps they deserve a dedicated place as @tompollard suggested in this 2nd thought on the topic. It would probably make sense to create a general utils module in this repository at some point. If you prefer that option feel free to set it up or let me know and I'd be happy to do so. As far as I'm concerned, having them in a subfolder under formats/ is also fine.

I think the cleanest option is to store rand_access.py, waveform_reader.py, waveform_writer.py in a separate "DICOM-waveform" repository, because (as far as I understand it) the code implements the functionality for writing waveforms to DICOM. If we choose DICOM as the format, we will need to have a package that enables these functions (and actually, I assume there will be demand by the community for this functionality regardless). I'd be happy to help set up a pip installable version of this repo if you like this option.

If we want to go for the quick and easy option, my preference would be to move them to a submodule of the formats folder. I don't particularly like the idea of a generic utils submodule, because it has potential to become a dumping ground for random code.

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

Successfully merging this pull request may close these issues.

3 participants