Skip to content

Commit

Permalink
default pass
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Aug 22, 2023
1 parent fb6045c commit 471df66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/oneat/NEATModels/neat_densevollnet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from oneat.NEATUtils import plotters
import numpy as np
from oneat.NEATUtils import utils
from oneat.NEATUtils.utils import save_volume, pad_timelapse, get_nearest_volume, load_json, volumeyoloprediction, normalizeFloatZeroOne, GenerateVolumeMarkers, MakeForest,save_volume_csv, volume_dynamic_nms
from oneat.NEATUtils.utils import save_volume, create_sub_image, pad_timelapse, get_nearest_volume, load_json, volumeyoloprediction, normalizeFloatZeroOne, GenerateVolumeMarkers, MakeForest,save_volume_csv, volume_dynamic_nms
from keras import callbacks
import os
import sys
Expand Down Expand Up @@ -314,10 +314,7 @@ def predict(self,
print(f'zero padded image shape ${self.image.shape}')
self.second_pass_predict()
if self.remove_markers == None:
self.pad_width = (self.config['imagey'], self.config['imagex'])
self.image = np.zeros([self.originalimage.shape[0], self.originalimage.shape[1], self.originalimage.shape[2] + self.pad_width[0], self.originalimage.shape[3] + self.pad_width[1] ])
for i in range(self.originalimage.shape[0]):
self.image[i,:] = pad_timelapse(self.originalimage[i,:], self.pad_width)
self.image = create_sub_image(self.originalimage,self.config['imagez'],self.config['imagey'], self.config['imagex'])
self.default_pass_predict()


Expand Down
8 changes: 2 additions & 6 deletions src/oneat/NEATModels/neat_vollnet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from oneat.NEATUtils import plotters
import numpy as np
from oneat.NEATUtils import utils
from oneat.NEATUtils.utils import save_volume, pad_timelapse, get_nearest_volume, load_json, volumeyoloprediction, normalizeFloatZeroOne, GenerateVolumeMarkers, MakeForest,save_volume_csv, volume_dynamic_nms
from oneat.NEATUtils.utils import save_volume, create_sub_image, pad_timelapse, get_nearest_volume, load_json, volumeyoloprediction, normalizeFloatZeroOne, GenerateVolumeMarkers, MakeForest,save_volume_csv, volume_dynamic_nms
from keras import callbacks
import os
import sys
Expand Down Expand Up @@ -311,12 +311,8 @@ def predict(self,
print(f'zero padded image shape ${self.image.shape}')
self.second_pass_predict()
if self.remove_markers == None:
self.pad_width = (self.config['imagey'], self.config['imagex'])
self.image = np.zeros([self.originalimage.shape[0], self.originalimage.shape[1], self.originalimage.shape[2] + self.pad_width[0], self.originalimage.shape[3] + self.pad_width[1] ])

for i in range(self.originalimage.shape[0]):
self.image[i,:] = pad_timelapse(self.originalimage[i,:], self.pad_width)
self.image = self.originalimage
self.image = create_sub_image(self.originalimage,self.config['imagez'],self.config['imagey'], self.config['imagex'])
self.default_pass_predict()


Expand Down
15 changes: 15 additions & 0 deletions src/oneat/NEATUtils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,21 @@ def load_full_training_data(directory, filename, axes=None, verbose=True):

return (X, Y), axes

def create_sub_image(image, n, m, p):

t, z, y, x = image.shape

z_remainder = z % n
y_remainder = y % m
x_remainder = x % p

new_z = z - z_remainder
new_y = y - y_remainder
new_x = x - x_remainder

sub_image = image[:, :new_z, :new_y, :new_x]

return sub_image

def pad_timelapse(image, pad_width):

Expand Down

0 comments on commit 471df66

Please sign in to comment.