1+ import hashlib
12import sys
23from pathlib import Path
34from datetime import time as dt_time
@@ -21,6 +22,10 @@ def _assert_no_acquisition_temp_cols(df: pd.DataFrame) -> None:
2122 assert ACQUISITION_TEMP_COLS .isdisjoint (df .columns )
2223
2324
25+ def _expected_merged_volume_id (* volume_ids : str ) -> str :
26+ return hashlib .sha1 ("|" .join (sorted (volume_ids )).encode ("utf-8" )).hexdigest ()
27+
28+
2429def test_normalize_clean_args_prefers_optional_csv_path (tmp_path ):
2530 csv_pos = tmp_path / "pos.csv"
2631 csv_opt = tmp_path / "opt.csv"
@@ -304,34 +309,8 @@ def test_correct_volume_ids_merging(tmp_path, capsys):
304309 }
305310 )
306311 out = clean .correct_volume_ids (df .copy (), z_tolerance = 1e-3 )
307- # both rows should now have the canonical (sorted) volume id 'b'
308- assert set (out ["volume_id" ].unique ()) == {"b" }
309-
310-
311- def test_correct_volume_ids_extracts_z_from_string_image_position_patient ():
312- df = pd .DataFrame (
313- {
314- "patient_key" : ["p" , "p" ],
315- "study_id" : ["s" , "s" ],
316- "series_id" : ["sr" , "sr" ],
317- "ImageType" : ["A" , "A" ],
318- "ImageOrientationPatient" : [
319- (1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ),
320- (1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 ),
321- ],
322- "SliceThickness" : [1.0 , 1.0 ],
323- "PixelSpacingXY" : [0.7 , 0.7 ],
324- "volume_id" : ["b" , "c" ],
325- "ImagePositionPatient" : [
326- "[100.0, 0.0, 0.0]" ,
327- "[100.0, 0.0, 5.0]" ,
328- ],
329- }
330- )
331-
332- out = clean .correct_volume_ids (df .copy (), z_tolerance = 1e-3 )
333-
334- assert set (out ["volume_id" ].unique ()) == {"b" }
312+ # both rows should now have the canonical merged volume id
313+ assert set (out ["volume_id" ].unique ()) == {_expected_merged_volume_id ("b" , "c" )}
335314
336315
337316def test_parse_ipp_accepts_dicom_backslash_string ():
0 commit comments