@@ -145,18 +145,16 @@ def load_swcs(self, swc_pointer):
145145
146146 # --- Sample Image Patches ---
147147 def __getitem__ (self , dummy_input ):
148- # Sample image patch
148+ # Get image patches
149149 brain_id = self .sample_brain ()
150150 voxel = self .sample_voxel (brain_id )
151151 noise = self .read_patch (brain_id , voxel )
152152 mn , mx = np .percentile (noise , self .normalization_percentiles )
153-
154- # Denoise image patch
155153 denoised = bm4d (noise , self .sigma_bm4d )
156154
157155 # Normalize image patches
158- noise = ( noise - mn ) / max (mx - mn , 1 )
159- denoised = ( denoised - mn ) / max (mx - mn , 1 )
156+ noise = np . clip (( noise - mn ) / max (mx - mn , 1 ), 0 , 10 )
157+ denoised = np . clip (( denoised - mn ) / max (mx - mn , 1 ), 0 , 10 )
160158 return noise , denoised , (mn , mx )
161159
162160 def sample_brain (self ):
@@ -474,8 +472,8 @@ def ingest_example(self, brain_id, voxel):
474472 denoised = bm4d (noise , self .sigma_bm4d )
475473
476474 # Normalize image patches
477- noise = ( noise - mn ) / max (mx - mn , 1 )
478- denoised = ( denoised - mn ) / max (mx - mn , 1 )
475+ noise = np . clip (( noise - mn ) / max (mx - mn , 1 ), 0 , 10 )
476+ denoised = np . clip (( denoised - mn ) / max (mx - mn , 1 ), 0 , 10 )
479477
480478 # Store results
481479 self .example_ids .append ((brain_id , voxel ))
0 commit comments