Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinkya-kulkarni authored Feb 7, 2024
1 parent 25f9b83 commit bd14c23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions DataSetPreparation/PrepareDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@

print()

count_organoid_number_and_report(os.path.join('Annotations', 'masks'))

count_organoid_number_and_report(os.path.join('Test_Set', 'GroundTruthMasks'))
count_organoid_number_by_type(os.path.join('Annotations', 'masks'))
print()
count_organoid_number_by_type(os.path.join('Test_Set', 'GroundTruthMasks'))

print()

Expand Down
26 changes: 18 additions & 8 deletions DataSetPreparation/PrepareDatasetModules.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,21 +714,31 @@ def validate_and_count_images():

##################################################################################################

def count_organoid_number_and_report(folder_path):
total_blobs = 0
file_count = 0
def count_organoid_number_by_type(folder_path):
total_human_blobs = 0
total_mouse_blobs = 0
human_file_count = 0
mouse_file_count = 0

for filename in tqdm(sorted(os.listdir(folder_path)), desc = 'Calculating statistics on masks', leave = True):
for filename in tqdm(sorted(os.listdir(folder_path)), desc='Calculating statistics on masks', leave=True):
if filename.endswith(".tiff") or filename.endswith(".tif"):
file_path = os.path.join(folder_path, filename)
with Image.open(file_path) as img:
img_array = np.array(img)
unique_values = np.unique(img_array)

# Subtract 1 for background (assuming 0 is background)
total_blobs += len(unique_values) - 1 if 0 in unique_values else len(unique_values)
file_count += 1
# Count blobs (subtract 1 for background if 0 is present)
blob_count = len(unique_values) - 1 if 0 in unique_values else len(unique_values)

print(f"Total number of Organoids in '{folder_path}' for {file_count} masks is: {total_blobs}")
# Check if the file is human or mouse and update counts
if filename.startswith("human_"):
total_human_blobs += blob_count
human_file_count += 1
elif filename.startswith("mouse_"):
total_mouse_blobs += blob_count
mouse_file_count += 1

print(f"Total number of Human Organoids in '{folder_path}' for {human_file_count} masks is: {total_human_blobs}")
print(f"Total number of Mouse Organoids in '{folder_path}' for {mouse_file_count} masks is: {total_mouse_blobs}")

##################################################################################################
Binary file modified DataSetPreparation/Training_Data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bd14c23

Please sign in to comment.