@@ -78,6 +78,7 @@ class TomographyContext(Context):
7878 ProcessingParameter ("image_size_y" , "Image Size Y" ),
7979 ProcessingParameter ("pixel_size_on_image" , "Pixel Size" ),
8080 ProcessingParameter ("motion_corr_binning" , "Motion Correction Binning" ),
81+ ProcessingParameter ("frame_count" , "Number of image frames" ),
8182 ProcessingParameter ("num_eer_frames" , "Number of EER Frames" ),
8283 ]
8384
@@ -92,31 +93,6 @@ def __init__(self, acquisition_software: str, basepath: Path):
9293 self ._processing_job_stash : dict = {}
9394 self ._lock : RLock = RLock ()
9495
95- def _flush_data_collections (self ):
96- logger .info (
97- f"Flushing { len (self ._data_collection_stash )} data collection API calls"
98- )
99- for dc_data in self ._data_collection_stash :
100- data = {
101- ** dc_data [2 ],
102- ** {
103- k : v
104- for k , v in dc_data [1 ].data_collection_parameters .items ()
105- if k != "tag"
106- },
107- }
108- capture_post (dc_data [0 ], json = data )
109- self ._data_collection_stash = []
110-
111- def _flush_processing_jobs (self ):
112- logger .info (
113- f"Flushing { len (self ._processing_job_stash .keys ())} processing job API calls"
114- )
115- for v in self ._processing_job_stash .values ():
116- for pd in v :
117- requests .post (pd [0 ], json = pd [1 ])
118- self ._processing_job_stash = {}
119-
12096 def _file_transferred_to (
12197 self , environment : MurfeyInstanceEnvironment , source : Path , file_path : Path
12298 ):
@@ -227,8 +203,18 @@ def _add_tilt(
227203 self ._tilt_series_sizes [tilt_series ] = 0
228204 try :
229205 if environment :
230- url = f"{ str (environment .url .geturl ())} /visits/{ environment .visit } /{ environment .murfey_session } /start_data_collection"
231- data = {
206+ dcg_url = f"{ str (environment .url .geturl ())} /visits/{ str (environment .visit )} /{ environment .murfey_session } /register_data_collection_group"
207+ dcg_data = {
208+ "experiment_type" : "tomo" ,
209+ "experiment_type_id" : 36 ,
210+ "tag" : str (self ._basepath ),
211+ "atlas" : "" ,
212+ "sample" : None ,
213+ }
214+ capture_post (dcg_url , json = dcg_data )
215+
216+ dc_url = f"{ str (environment .url .geturl ())} /visits/{ environment .visit } /{ environment .murfey_session } /start_data_collection"
217+ dc_data = {
232218 "experiment_type" : "tomography" ,
233219 "file_extension" : file_path .suffix ,
234220 "acquisition_software" : self ._acquisition_software ,
@@ -245,7 +231,7 @@ def _add_tilt(
245231 environment .data_collection_parameters
246232 and environment .data_collection_parameters .get ("voltage" )
247233 ):
248- data .update (
234+ dc_data .update (
249235 {
250236 "voltage" : environment .data_collection_parameters [
251237 "voltage"
@@ -264,51 +250,16 @@ def _add_tilt(
264250 ],
265251 }
266252 )
253+ capture_post (dc_url , json = dc_data )
254+
267255 proc_url = f"{ str (environment .url .geturl ())} /visits/{ environment .visit } /{ environment .murfey_session } /register_processing_job"
268- if (
269- environment .data_collection_group_ids .get (str (self ._basepath ))
270- is None
271- ):
272- self ._data_collection_stash .append ((url , environment , data ))
273- self ._processing_job_stash [tilt_series ] = [
274- (
275- proc_url ,
276- {
277- "tag" : tilt_series ,
278- "source" : str (self ._basepath ),
279- "recipe" : "em-tomo-preprocess" ,
280- "experiment_type" : "tomography" ,
281- },
282- )
283- ]
284- self ._processing_job_stash [tilt_series ].append (
285- (
286- proc_url ,
287- {
288- "tag" : tilt_series ,
289- "source" : str (self ._basepath ),
290- "recipe" : "em-tomo-align" ,
291- "experiment_type" : "tomography" ,
292- },
293- )
294- )
295- else :
296- capture_post (url , json = data )
297- capture_post (
298- proc_url ,
299- json = {
300- "tag" : tilt_series ,
301- "source" : str (self ._basepath ),
302- "recipe" : "em-tomo-preprocess" ,
303- "experiment_type" : "tomography" ,
304- },
305- )
256+ for recipe in ("em-tomo-preprocess" , "em-tomo-align" ):
306257 capture_post (
307258 proc_url ,
308259 json = {
309260 "tag" : tilt_series ,
310261 "source" : str (self ._basepath ),
311- "recipe" : "em-tomo-align" ,
262+ "recipe" : recipe ,
312263 "experiment_type" : "tomography" ,
313264 },
314265 )
@@ -361,6 +312,9 @@ def _add_tilt(
361312 "dose_per_frame" : environment .data_collection_parameters .get (
362313 "dose_per_frame" , 0
363314 ),
315+ "frame_count" : environment .data_collection_parameters .get (
316+ "frame_count" , 0
317+ ),
364318 "mc_binning" : environment .data_collection_parameters .get (
365319 "motion_corr_binning" , 1
366320 ),
@@ -591,6 +545,7 @@ def gather_metadata(
591545 mdoc_metadata : OrderedDict = OrderedDict ({})
592546 mdoc_metadata ["experiment_type" ] = "tomography"
593547 mdoc_metadata ["voltage" ] = float (mdoc_data ["Voltage" ])
548+ mdoc_metadata ["frame_count" ] = int (mdoc_data_block ["NumSubFrames" ])
594549 mdoc_metadata ["image_size_x" ] = int (mdoc_data ["ImageSize" ][0 ])
595550 mdoc_metadata ["image_size_y" ] = int (mdoc_data ["ImageSize" ][1 ])
596551 mdoc_metadata ["magnification" ] = int (mdoc_data_block ["Magnification" ])
@@ -658,6 +613,9 @@ def gather_metadata(
658613 mdoc_metadata ["num_eer_frames" ] = murfey .util .eer .num_frames (
659614 metadata_file .parent / data_file
660615 )
616+ mdoc_metadata ["frame_count" ] = int (
617+ mdoc_metadata ["eer_fractionation" ] / mdoc_metadata ["num_eer_frames" ]
618+ )
661619 except Exception as e :
662620 logger .error (f"Exception encountered in metadata gathering: { str (e )} " )
663621 return OrderedDict ({})
0 commit comments