#!/usr/bin/env python # coding: utf-8 # # Fiber Analysis; Modified from FiberFit Software # ## software is from [this paper](https://link.springer.com/article/10.1007/s10237-016-0776-3) and Github with original program can be viewed [here.](https://github.com/NTMatBoiseState/FiberFit/tree/master/src/fiberfit_model) # #### this software below is same as above, but it allows for bulk proccessing and provides export of raw data # # ### Steps: First, Upload your Images for analysis. # In[10]: from widgetsmp import s,run,save,clear #,run2 from src.foruploading5 import ff,upload,prepimages import ipywidgets as widgets from IPython.display import display, Markdown, clear_output from ipywidgets import interact, interact_manual import os import glob get_ipython().run_line_magic('matplotlib', 'inline') ## Remove blank file from output folder files = glob.glob('Data/*',recursive=True) for f in files: try: os.remove(f) except OSError as e: print("Error: %s : %s" % (f, e.strerror)) s = widgets.FileUpload(accept='', multiple=True) upload(s) s # ### Next, Run Code. Input maximum and minimum fiber thickness (unit - pixels) for fibers. Suggested values are shown in boxes, but still need to be typed in the box. Output will be in "output" folder on home page. CSV output provides alignment data in order of images uploaded. # In[11]: run(_)### Next, Run Code. Input maximum and minimum fiber thickness for fibers. Suggested values are shown in boxes, but still need to be typed in the box. Output will be in "output" folder on home page. Can Download images and .csv from there (working on including .zip file download) # ### Next, Create zip file to download. # In[3]: get_ipython().system('tar chvfz notebook.tar.gz output/*;') # ### Finally, download output file by clicking on download link. Files include images for analysis and bulk .csv file. Delete files in Data and output file by clicking on clear data button prior to running a new set of files. # In[4]: save(_) clear(_) # ### Next, if desired, run code below for color maps of fiber orientation and diameter thickness (code modified from [this paper](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0215137). Again, output will be in "output" folder. # ###### Note: These color maps are from a program called Quanfima. This is a method that utilizes alternative calculation method than above. It takes longer to calculate, but can be used qualitatively against csv + image outputs in above program to confirm if similar results. PNG or JPEG files are suggested for speedier calculations. # ### Steps: First, Upload a single image for analysis # In[5]: s = widgets.FileUpload(accept='', multiple=True) upload(s) s # ### Steps: Next, run analysis # In[6]: run2(_) # ## Create output file to download # In[7]: get_ipython().system('tar chvfz notebook.tar.gz output/*;') # ## Download output file by clicking on download link. Files include images shown above. Click clear data to clear input and output data to run again. # In[8]: save(_) clear(_) # In[ ]: