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 471df66 commit f07a93c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/oneat/NEATModels/neat_densevollnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def predict(self,
print(f'zero padded image shape ${self.image.shape}')
self.second_pass_predict()
if self.remove_markers == None:
self.image = create_sub_image(self.originalimage,self.config['imagez'],self.config['imagey'], self.config['imagex'])
self.image = create_sub_image(self.originalimage,self.config['imagez'],self.config['imagey'], self.config['imagex'], self.stride)
self.default_pass_predict()


Expand Down
2 changes: 1 addition & 1 deletion src/oneat/NEATModels/neat_vollnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def predict(self,
self.second_pass_predict()
if self.remove_markers == None:

self.image = create_sub_image(self.originalimage,self.config['imagez'],self.config['imagey'], self.config['imagex'])
self.image = create_sub_image(self.originalimage,self.config['imagez'],self.config['imagey'], self.config['imagex'], self.stride)
self.default_pass_predict()


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

return (X, Y), axes

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

def create_sub_image(image, n, m, p, stride):
t, z, y, x = image.shape
sub_images = []

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]
for t_idx in range(t):
sub_image_t = image[t_idx]

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

new_z = z - z_remainder + (n - 1)
new_y = y - y_remainder + (m - 1)
new_x = x - x_remainder + (p - 1)

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

pad_z = (new_z - z) % stride
pad_y = (new_y - y) % stride
pad_x = (new_x - x) % stride

sub_image_padded = np.pad(sub_image, ((0, pad_z), (0, pad_y), (0, pad_x)), mode='constant')

sub_images.append(sub_image_padded)

return sub_image
return np.array(sub_images)

def pad_timelapse(image, pad_width):

Expand Down

0 comments on commit f07a93c

Please sign in to comment.