Skip to content

Commit

Permalink
Update BoneJ_Module_Example_Batch.py
Browse files Browse the repository at this point in the history
Added arguments for fiji path and roi file path
  • Loading branch information
harshamarupudi56 authored Nov 17, 2023
1 parent 20f43f7 commit b2bd011
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Examples/BoneJ_Module_Example_Batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,44 @@
import sys, os
from glob import glob
import csv
# sys.path.append('/gpfs_projects/sriharsha.marupudi/BoneJ_Headless-main/BoneJ_Scripts/')
from argparse import ArgumentParser

from BoneJ_Module import Thickness
from BoneJ_Module import Spacing
from BoneJ_Module import Area_VolumeFraction
from BoneJ_Module import Connectivity
from BoneJ_Module import Anisotropy
from BoneJ_Module import Ellipsoid_Factor

filepath = "/BoneJ_Headless-main/ROIs/"
voxel_size = [25,25,25] #microns
fiji_path = "~/Fiji.app/ImageJ-linux64"
outdir = "/BoneJ_Headless-main/ROIs/"
csv_path = outdir + "output_metrics.csv"

with open(csv_path, 'w', newline='') as csv_file:
csvwriter = csv.writer(csv_file)
csvwriter.writerow(["ROI Name", "Tb.Th Mean (µm)", "Tb.Sp Mean (µm)", "DA", "BV/TV", "Conn.D (µm⁻³)", "Median EF"])
if __name__ == "__main__":

parser = ArgumentParser()
parser.add_argument("-i", "--input", "--ROI", dest="ROI", default=os.path.join(os.path.dirname(os.path.dirname(__file__)), "ROIs/emu.nrrd"))
parser.add_argument("-f", "--fiji", "--fiji-path", dest="fiji_path", default="~/Fiji.app/ImageJ-linux64")
args = parser.parse_args()

fiji_path = args.fiji_path
filepath = args.ROI


# Check that those filepaths actually exist
if os.path.exists(fiji_path):
print(f"Fiji installation specified: {fiji_path}")
else:
print(f"Unrecognized file path: {fiji_path}")

if os.path.exists(filepath):
print(f"Loading ROI from {filepath}")
else:
raise Exception(f"Unrecognized file path: {filepath}")

Dir = glob(filepath+"*.nrrd")
for file in Dir:

Expand Down

0 comments on commit b2bd011

Please sign in to comment.