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

'FileDataset' object has no attribute 'SeriesDate' #20

Closed
pchlap opened this issue May 11, 2021 · 1 comment
Closed

'FileDataset' object has no attribute 'SeriesDate' #20

pchlap opened this issue May 11, 2021 · 1 comment

Comments

@pchlap
Copy link
Contributor

pchlap commented May 11, 2021

Hi,

We have come across this error on a few datasets we are using. Including the LCTSC dataset from TCIA: http:https://doi.org/10.7937/K9/TCIA.2017.3r3fvz08

/usr/local/lib/python3.6/dist-packages/rt_utils/rtstruct_builder.py:22: in create_new
    ds = ds_helper.create_rtstruct_dataset(series_data)
/usr/local/lib/python3.6/dist-packages/rt_utils/ds_helper.py:15: in create_rtstruct_dataset
    add_study_and_series_information(ds, series_data)
/usr/local/lib/python3.6/dist-packages/rt_utils/ds_helper.py:68: in add_study_and_series_information
    ds.SeriesDate = reference_ds.SeriesDate

AttributeError: 'FileDataset' object has no attribute 'SeriesDate'

The problem is our DICOMs don't have the SeriesDate attribute. Is this something any one else has come across? Could we consider adjusting the code only copy over that attribute if it is available? I'd be happy to look at submitting a pull request if this is something you are interested in.

Thanks!
Phil

@awtkns
Copy link
Contributor

awtkns commented May 11, 2021

That would be awesome if you could PR this, we are always looking for new contributors to help make rt-utils a better community tool!

The implementation for it should be fairly simple and would essentially just entail changing the dates to provide a default value as we do for the StudyDescription, etc... (shown below)

def add_study_and_series_information(ds: FileDataset, series_data):
    reference_ds = series_data[0] # All elements in series should have the same data
    ds.StudyDate = reference_ds.StudyDate
    ds.SeriesDate = reference_ds.SeriesDate
    ds.StudyTime = reference_ds.StudyTime
    ds.SeriesTime = reference_ds.SeriesTime
    ds.StudyDescription = getattr(reference_ds, 'StudyDescription', '')
    ds.SeriesDescription = getattr(reference_ds, 'SeriesDescription', '')
    ds.StudyInstanceUID = reference_ds.StudyInstanceUID
    ds.SeriesInstanceUID = generate_uid()
    ds.StudyID = reference_ds.StudyID
    ds.SeriesNumber = "1"

This issue is similar to #19 @carluri

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

2 participants