@@ -96,20 +96,10 @@ def ensure_dcg_exists(
9696 logger .info (
9797 f"Looking for atlas XML file in metadata directory { str ((source_visit_dir / partial_path ).parent )} "
9898 )
99- atlas_xml_path = list (
100- (source_visit_dir / partial_path ).parent .glob ("Atlas_*.xml" )
101- )[0 ]
102- logger .info (f"Atlas XML path { str (atlas_xml_path )} found" )
103- with open (atlas_xml_path , "rb" ) as atlas_xml :
104- atlas_xml_data = xmltodict .parse (atlas_xml )
105- atlas_original_pixel_size = float (
106- atlas_xml_data ["MicroscopeImage" ]["SpatialScale" ]["pixelSize" ]["x" ][
107- "numericValue"
108- ]
109- )
110- # need to calculate the pixel size of the downscaled image
111- atlas_pixel_size = atlas_original_pixel_size * 7.8
112- logger .info (f"Atlas image pixel size determined to be { atlas_pixel_size } " )
99+
100+ dcg_tag = "/" .join (
101+ [part for part in metadata_source .parts if part != environment .visit ]
102+ ).replace ("//" , "/" )
113103
114104 for p in partial_path .split ("/" ):
115105 if p .startswith ("Sample" ):
@@ -122,20 +112,39 @@ def ensure_dcg_exists(
122112 atlas = Path (partial_path ), sample = sample
123113 )
124114
125- dcg_tag = "/" .join (
126- [part for part in metadata_source .parts if part != environment .visit ]
127- ).replace ("//" , "/" )
128- dcg_data = {
129- "experiment_type_id" : experiment_type_id ,
130- "tag" : dcg_tag ,
131- "atlas" : str (
132- _atlas_destination (environment , session_file .parent , token )
133- / environment .samples [metadata_source ].atlas .parent
134- / atlas_xml_path .with_suffix (".jpg" ).name
135- ).replace ("//" , "/" ),
136- "sample" : environment .samples [metadata_source ].sample ,
137- "atlas_pixel_size" : atlas_pixel_size ,
138- }
115+ if atlas_xml_search := list (
116+ (source_visit_dir / partial_path ).parent .glob ("Atlas_*.xml" )
117+ ):
118+ atlas_xml_path = atlas_xml_search [0 ]
119+ logger .info (f"Atlas XML path { str (atlas_xml_path )} found" )
120+ with open (atlas_xml_path , "rb" ) as atlas_xml :
121+ atlas_xml_data = xmltodict .parse (atlas_xml )
122+ atlas_original_pixel_size = float (
123+ atlas_xml_data ["MicroscopeImage" ]["SpatialScale" ]["pixelSize" ]["x" ][
124+ "numericValue"
125+ ]
126+ )
127+ # need to calculate the pixel size of the downscaled image
128+ atlas_pixel_size = atlas_original_pixel_size * 7.8
129+ logger .info (f"Atlas image pixel size determined to be { atlas_pixel_size } " )
130+
131+ dcg_data = {
132+ "experiment_type_id" : experiment_type_id ,
133+ "tag" : dcg_tag ,
134+ "atlas" : str (
135+ _atlas_destination (environment , session_file .parent , token )
136+ / environment .samples [metadata_source ].atlas .parent
137+ / atlas_xml_path .with_suffix (".jpg" ).name
138+ ).replace ("//" , "/" ),
139+ "sample" : environment .samples [metadata_source ].sample ,
140+ "atlas_pixel_size" : atlas_pixel_size ,
141+ }
142+ else :
143+ dcg_data = {
144+ "experiment_type_id" : experiment_type_id ,
145+ "tag" : dcg_tag ,
146+ "sample" : environment .samples [metadata_source ].sample ,
147+ }
139148 capture_post (
140149 base_url = str (environment .url .geturl ()),
141150 router_name = "workflow.router" ,
0 commit comments