|
7 | 7 | from murfey.client.context import Context, _atlas_destination, _get_source |
8 | 8 | from murfey.client.instance_environment import MurfeyInstanceEnvironment |
9 | 9 | from murfey.util.client import capture_post |
| 10 | +from murfey.util.spa_metadata import get_grid_square_atlas_positions |
10 | 11 |
|
11 | 12 | logger = logging.getLogger("murfey.client.contexts.atlas") |
12 | 13 |
|
@@ -158,3 +159,56 @@ def post_transfer_epu( |
158 | 159 | logger.info( |
159 | 160 | f"Registered data collection group for atlas {str(transferred_atlas_jpg)!r}" |
160 | 161 | ) |
| 162 | + |
| 163 | + elif ( |
| 164 | + environment |
| 165 | + and "Atlas_" in transferred_file.stem |
| 166 | + and transferred_file.suffix == ".dm" |
| 167 | + ): |
| 168 | + # Register all grid squares on this atlas |
| 169 | + gs_pix_positions = get_grid_square_atlas_positions(transferred_file) |
| 170 | + for gs, pos_data in gs_pix_positions.items(): |
| 171 | + if pos_data: |
| 172 | + capture_post( |
| 173 | + base_url=str(environment.url.geturl()), |
| 174 | + router_name="session_control.spa_router", |
| 175 | + function_name="register_grid_square", |
| 176 | + token=self._token, |
| 177 | + instrument_name=environment.instrument_name, |
| 178 | + session_id=environment.murfey_session, |
| 179 | + gsid=int(gs), |
| 180 | + data={ |
| 181 | + "tag": str(transferred_file.parent), |
| 182 | + "x_location": pos_data[0], |
| 183 | + "y_location": pos_data[1], |
| 184 | + "x_stage_position": pos_data[2], |
| 185 | + "y_stage_position": pos_data[3], |
| 186 | + "width": pos_data[4], |
| 187 | + "height": pos_data[5], |
| 188 | + "angle": pos_data[6], |
| 189 | + }, |
| 190 | + ) |
| 191 | + if gs_pix_positions: |
| 192 | + for p in transferred_file.parts: |
| 193 | + if p.startswith("Sample"): |
| 194 | + sample = int(p.replace("Sample", "")) |
| 195 | + break |
| 196 | + else: |
| 197 | + logger.warning( |
| 198 | + f"Sample could not be identified for {transferred_file}" |
| 199 | + ) |
| 200 | + return |
| 201 | + capture_post( |
| 202 | + base_url=str(environment.url.geturl()), |
| 203 | + router_name="session_control.spa_router", |
| 204 | + function_name="register_atlas", |
| 205 | + token=self._token, |
| 206 | + instrument_name=environment.instrument_name, |
| 207 | + session_id=environment.murfey_session, |
| 208 | + data={ |
| 209 | + "name": f"{environment.visit}-sample-{sample}", |
| 210 | + "acquisition_uuid": environment.acquisition_uuid, |
| 211 | + "register_grid": True, |
| 212 | + "tag": str(transferred_file.parent), |
| 213 | + }, |
| 214 | + ) |
0 commit comments