Skip to content

Commit

Permalink
Merge pull request #32 from samarthshetty09/dev
Browse files Browse the repository at this point in the history
step3_v2
  • Loading branch information
samarthshetty09 authored Jul 15, 2024
2 parents 48bfb9a + 7898cc4 commit 7685936
Showing 1 changed file with 18 additions and 29 deletions.
47 changes: 18 additions & 29 deletions step3_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def OAM_23121_tp3(M, cel, no_obj1, A):

# Sort based on the first detection
sortOrder = np.argsort(cell_exists0[0, :]) #check the sort !TODO:
sorted_order = sorted(sortOrder)
cell_exists = cell_exists0[:, sortOrder]
# sortOrder = sorted(sortOrder)
# sortOrder.append(len(sortOrder))
Expand All @@ -650,7 +651,7 @@ def OAM_23121_tp3(M, cel, no_obj1, A):


for itt3 in range(len(sortOrder)):
pix3 = (Mask5 == sortOrder[itt3]) # here
pix3 = (Mask5 == sortOrder[itt3]+1) # here
Mask6[pix3] = itt3 + 1# reassign

# Get cell presence 3
Expand All @@ -660,23 +661,21 @@ def OAM_23121_tp3(M, cel, no_obj1, A):
no_obj1 = int(obj.max())
A = 1

tic = time.time()
tp_im = np.zeros((no_obj1, im_no))

for cel in range(1, no_obj1 + 1):
Ma = (Mask7 == cel)

for ih in range(numbM):
if Ma[:, :, ih].sum() != 0:
tp_im[cel-1, ih] = 1


tp_im[cel - 1, :] = ((Mask7 == cel).sum(axis=(0, 1)) != 0).astype(int)
if cel > 1 and np.sum(tp_im[cel - 1]) == 0:
tp_im[cel - 1] = tp_im[cel - 2]
toc = time.time()
print(f'Elapsed time is {toc - tic} seconds.')

# plt.figure()
# plt.imshow(tp_im, aspect='auto')
# plt.title("Cell Presence Over Time")
# plt.xlabel("Time")
# plt.ylabel("Cells")
# plt.show()
plt.figure()
plt.imshow(tp_im, aspect='auto')
plt.title("Cell Presence Over Time")
plt.xlabel("Time")
plt.ylabel("Cells")
plt.show()


# Calculate size
Expand All @@ -686,23 +685,13 @@ def OAM_23121_tp3(M, cel, no_obj1, A):
all_ob = np.zeros((no_obj, im_no))

tic = time.time()

for ccell in range(1, no_obj + 1):
Maa = (Mask7 == ccell + 1)

for i in range(im_no):
pix = np.sum(Maa[:, :, i])
all_ob[ccell-1, i] = pix


# zero_counts = np.sum(all_ob == 0, axis=1)
# sorted_indices = np.argsort(zero_counts)
# sorted_arr = all_ob[sorted_indices]

all_ob[ccell - 1, :] = np.sum(Mask7 == ccell + 1, axis=(0, 1))
if ccell > 1 and not np.any(all_ob[ccell - 1]):
all_ob[ccell - 1] = all_ob[ccell - 2]
toc = time.time()
print(f'Elapsed time is {toc - tic} seconds.')


print(f'Elapsed time is {toc - tic} seconds.')

plt.figure()
plt.imshow(all_ob, aspect='auto', cmap='viridis')
Expand Down

0 comments on commit 7685936

Please sign in to comment.