-
Notifications
You must be signed in to change notification settings - Fork 10
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
TCIA Adapter #121
TCIA Adapter #121
Changes from 12 commits
df37728
0e1615f
4e6f5a9
2e64eab
3d1f466
77aa3ef
45b7a7f
61f7345
1f92f66
bfb6d9c
075f6b3
8fb5cb8
e73962d
db6c261
07a80b6
5f196bc
bd914fa
3347918
dea672c
fec2b65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import respx | ||
import httpx | ||
|
||
from mds.agg_mds.adapters import get_metadata | ||
|
||
|
||
@respx.mock | ||
def test_get_metadata_tcia(): | ||
tcia_response = """ | ||
[ | ||
{ | ||
"StudyInstanceUID": "study_id_1", | ||
"StudyDate": "", | ||
"StudyDescription": "Collection One.", | ||
"PatientAge": "", | ||
"PatientID": "", | ||
"PatientName": "", | ||
"PatientSex": "", | ||
"EthnicGroup": "", | ||
"Collection": "Collection1", | ||
"SeriesCount": 1, | ||
"LongitudinalTemporalEventType": "", | ||
"LongitudinalTemporalOffsetFromEvent": 0 | ||
}, | ||
{ | ||
"StudyInstanceUID": "study_id_2", | ||
"StudyDate": "", | ||
"StudyDescription": "Collection Two.", | ||
"PatientAge": "", | ||
"PatientID": "", | ||
"PatientName": "", | ||
"PatientSex": "", | ||
"EthnicGroup": "", | ||
"Collection": "Collection2", | ||
"SeriesCount": 2, | ||
"LongitudinalTemporalEventType": "", | ||
"LongitudinalTemporalOffsetFromEvent": 1 | ||
} | ||
] | ||
""" | ||
|
||
field_mappings = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need PatientID, EthnicGroup, Patient Sex and SeriesCount also in the final fields There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just tests. Though, I have added the fields for clarification. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding the fields. I had requested it to align with CTDS guidelines, but as long as it works reliably, I’m okay to proceed. |
||
"_unique_id": "path:StudyInstanceUID", | ||
"commons": "TCIA", | ||
"study_title": "path:StudyDescription", | ||
"program_name": "path:Collection", | ||
"description": "", | ||
"tags": [], | ||
} | ||
|
||
respx.get("http://test/ok").mock(side_effect=httpx.HTTPError) | ||
assert ( | ||
get_metadata("tcia", "http://test/ok", filters=None, mappings=field_mappings) | ||
== {} | ||
) | ||
|
||
respx.get("http://test/ok").mock(side_effect=Exception) | ||
assert ( | ||
get_metadata("tcia", "http://test/ok", filters=None, mappings=field_mappings) | ||
== {} | ||
) | ||
|
||
respx.get( | ||
"http://test/ok", | ||
).mock(return_value=httpx.Response(status_code=200, content=tcia_response)) | ||
|
||
filters = {"size": 5} | ||
|
||
assert get_metadata( | ||
"tcia", "http://test/ok", filters=filters, mappings=field_mappings | ||
) == { | ||
"study_id_1": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On some level this is how the subject metadata coming out of adapter should be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just tests. From what I see it has the same structure to what you provided. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Appreciate that. My request was to meet the testing standards, but looking at time crunch, if it works as required, I’m fine moving forward There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am as well. |
||
"_guid_type": "discovery_metadata", | ||
"gen3_discovery": { | ||
"_unique_id": "study_id_1", | ||
"commons": "TCIA", | ||
"description": "TCIA data from collection: Collection1.", | ||
"program_name": "Collection1", | ||
"study_title": "Collection One.", | ||
"tags": [{"category": "program_name", "name": "Collection1"}], | ||
}, | ||
}, | ||
"study_id_2": { | ||
"_guid_type": "discovery_metadata", | ||
"gen3_discovery": { | ||
"_unique_id": "study_id_2", | ||
"commons": "TCIA", | ||
"description": "TCIA data from collection: Collection2.", | ||
"program_name": "Collection2", | ||
"study_title": "Collection Two.", | ||
"tags": [{"category": "program_name", "name": "Collection2"}], | ||
}, | ||
}, | ||
} |
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.
This TCIA response only test for subject level metadata. For study-level metadata coming from this URL I think the mapping should be like this
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 have added the part for study-level to the tests.
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 adding that