@@ -51,6 +51,55 @@ def stop(self):
5151 self .thread .join ()
5252 log .debug ("MultigridDirWatcher thread stop completed" )
5353
54+ def _handle_metadata (self , directory : Path ):
55+ self .notify (
56+ directory ,
57+ extra_directory = f"metadata_{ directory .name } " ,
58+ include_mid_path = False ,
59+ analyse = self ._analyse ,
60+ limited = True ,
61+ tag = "metadata" ,
62+ )
63+ self ._seen_dirs .append (directory )
64+
65+ def _handle_fractions (self , directory : Path , first_loop : bool ):
66+ processing_started = False
67+ for d02 in directory .glob ("Images-Disc*" ):
68+ if d02 not in self ._seen_dirs :
69+ # If 'skip_existing_processing' is set, do not process for
70+ # any data directories found on the first loop.
71+ # This allows you to avoid triggering processing again if Murfey is restarted
72+ self .notify (
73+ d02 ,
74+ include_mid_path = False ,
75+ remove_files = True ,
76+ analyse = (
77+ not (first_loop and self ._skip_existing_processing )
78+ if self ._analyse
79+ else False
80+ ),
81+ tag = "fractions" ,
82+ )
83+ self ._seen_dirs .append (d02 )
84+ processing_started = d02 in self ._seen_dirs
85+ if not processing_started :
86+ if (
87+ directory .is_dir ()
88+ and directory not in self ._seen_dirs
89+ and list (directory .iterdir ())
90+ ):
91+ self .notify (
92+ directory ,
93+ include_mid_path = False ,
94+ analyse = (
95+ not (first_loop and self ._skip_existing_processing )
96+ if self ._analyse
97+ else False
98+ ),
99+ tag = "fractions" ,
100+ )
101+ self ._seen_dirs .append (directory )
102+
54103 def _process (self ):
55104 first_loop = True
56105 while not self ._stopping :
@@ -75,53 +124,23 @@ def _process(self):
75124 )
76125 self ._seen_dirs .append (d )
77126 else :
78- if d .is_dir () and d not in self ._seen_dirs :
79- self .notify (
80- d ,
81- extra_directory = f"metadata_{ d .name } " ,
82- include_mid_path = False ,
83- analyse = self ._analyse ,
84- limited = True ,
85- tag = "metadata" ,
86- )
87- self ._seen_dirs .append (d )
88- processing_started = False
89- for d02 in (d .parent .parent / d .name ).glob ("Images-Disc*" ):
90- if d02 not in self ._seen_dirs :
91- # If 'skip_existing_processing' is set, do not process for
92- # any data directories found on the first loop.
93- # This allows you to avoid triggering processing again if Murfey is restarted
94- self .notify (
95- d02 ,
96- include_mid_path = False ,
97- remove_files = True ,
98- analyse = (
99- not (first_loop and self ._skip_existing_processing )
100- if self ._analyse
101- else False
102- ),
103- tag = "fractions" ,
104- )
105- self ._seen_dirs .append (d02 )
106- processing_started = d02 in self ._seen_dirs
107- if not processing_started :
108- d02 = d .parent .parent / d .name
109- if (
110- d02 .is_dir ()
111- and d02 not in self ._seen_dirs
112- and list ((d .parent .parent / d .name ).iterdir ())
113- ):
114- self .notify (
115- d02 ,
116- include_mid_path = False ,
117- analyse = (
118- not (first_loop and self ._skip_existing_processing )
119- if self ._analyse
120- else False
121- ),
122- tag = "fractions" ,
123- )
124- self ._seen_dirs .append (d02 )
127+ # hack for tomo multigrid metadata structure
128+ sample_dirs = list (d .glob ("Sample*" ))
129+ if d .is_dir () and len (sample_dirs ):
130+ for sample in sample_dirs :
131+ if len (list (sample .glob ("*.mdoc" ))):
132+ if sample not in self ._seen_dirs :
133+ self ._handle_metadata (sample )
134+ self ._handle_fractions (
135+ d .parent .parent .parent
136+ / f"{ d .parent .name } _{ d .name } " ,
137+ first_loop ,
138+ )
139+
140+ else :
141+ if d .is_dir () and d not in self ._seen_dirs :
142+ self ._handle_metadata (d )
143+ self ._handle_fractions (d .parent .parent / d .name , first_loop )
125144
126145 if first_loop :
127146 first_loop = False
0 commit comments