Skip to content

Commit

Permalink
Fixing datagraph module to resolve SEG compatibility issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
skim2257 committed Jul 31, 2024
1 parent 9be5df3 commit f163e06
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/imgtools/modules/datagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DataGraph:
5) edge_type:4 CT(key:study) -> PT(pair: study)
6) edge_type:5 RTDOSE(key: ref_pl) -> RTPLAN(pair: instance)
7) edge_type:6 RTPLAN(key: ref_rs) -> RTSTRUCT(pair: series/instance)
8) edge_type:7 SEG(key:ref_ct) -> CT(pair: series)
Once the edge table is formed, one can query on the graph to get the desired results. For uniformity, the supported query is list of modalities to consider
For ex:
Expand Down Expand Up @@ -141,6 +142,7 @@ def _form_edges(self, df):
plan = df[df["modality"] == "RTPLAN"]
dose = df[df["modality"] == "RTDOSE"]
struct = df[df["modality"] == "RTSTRUCT"]
seg = df[df["modality"] == "SEG"]
ct = df[df["modality"] == "CT"]
mr = df[df["modality"] == "MR"]
pet = df[df["modality"] == "PT"]
Expand Down Expand Up @@ -171,6 +173,11 @@ def _form_edges(self, df):
elif edge==5: # FORMS RTPLAN->RTDOSE on ref_pl
df_combined = pd.merge(plan, dose, left_on="instance_uid", right_on="reference_pl")

elif edge==7:
df_ct = pd.merge(ct, seg, left_on="series", right_on="reference_ct")
df_mr = pd.merge(mr, seg, left_on="series", right_on="reference_ct")
df_combined = pd.concat([df_ct, df_mr])

Check warning on line 179 in src/imgtools/modules/datagraph.py

View check run for this annotation

Codecov / codecov/patch

src/imgtools/modules/datagraph.py#L177-L179

Added lines #L177 - L179 were not covered by tests

else:
df_combined = pd.merge(struct, plan, left_on="instance_uid", right_on="reference_rs")

Expand Down Expand Up @@ -209,7 +216,7 @@ def _form_edge_study(self, df, all_study, study_id):
elif edge==1: # FORMS RTDOSE->CT
df_combined = pd.merge(ct, dose, left_on="series", right_on="reference_ct")

elif edge==2: # FORMS RTSTRUCT->CT on ref_ct to series
elif edge==2: # FORMS RTSTRUCT->CT/MR on ref_ct to series

Check warning on line 219 in src/imgtools/modules/datagraph.py

View check run for this annotation

Codecov / codecov/patch

src/imgtools/modules/datagraph.py#L219

Added line #L219 was not covered by tests
df_ct = pd.merge(ct, struct, left_on="series", right_on="reference_ct")
df_mr = pd.merge(mr, struct, left_on="series", right_on="reference_ct")
df_combined = pd.concat([df_ct, df_mr])
Expand All @@ -223,7 +230,7 @@ def _form_edge_study(self, df, all_study, study_id):
elif edge==5: # FORMS RTPLAN->RTDOSE on ref_pl
df_combined = pd.merge(plan, dose, left_on="instance", right_on="reference_pl")

elif edge==7: # FORMS RTSTRUCT->CT on ref_ct to series
elif edge==7: # FORMS SEG->CT/MR on ref_ct to series

Check warning on line 233 in src/imgtools/modules/datagraph.py

View check run for this annotation

Codecov / codecov/patch

src/imgtools/modules/datagraph.py#L233

Added line #L233 was not covered by tests
df_ct_seg = pd.merge(ct, seg, left_on="series", right_on="reference_ct")
df_mr_seg = pd.merge(mr, seg, left_on="series", right_on="reference_ct")
df_combined = pd.concat([df_ct_seg, df_mr_seg])
Expand Down

0 comments on commit f163e06

Please sign in to comment.