Guest User

Untitled

a guest
Jul 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. from skimage import io
  2.  
  3. from math import sqrt
  4. from skimage.feature import blob_log
  5.  
  6. import numpy as np
  7.  
  8. from pandas import DataFrame
  9.  
  10.  
  11. def start():
  12. while True:
  13. us_input = input(
  14. "Please enter the name of the file you'd like to analyze.n> "
  15. )
  16.  
  17. try:
  18. im = io.imread(us_input)
  19. break
  20. except FileNotFoundError:
  21. print(
  22. "That file doesn't seem to exist or has been entered incorrectly."
  23. )
  24.  
  25. neur_detect(im)
  26.  
  27.  
  28. def neur_detect(im):
  29. neurons = blob_log(im, min_sigma=1, max_sigma=30, threshold=.02, overlap=.1)
  30.  
  31. neur_props(neurons)
  32.  
  33.  
  34. def neur_props(blobs):
  35. num_neurons = len(blobs)
  36. print("nNumber of potential neurons detected: {}n".format(num_neurons))
  37.  
  38. results = []
  39.  
  40. for blob in blobs:
  41. y_row, x_col, r = blob
  42. properties = []
  43. properties.append(x_col / .769230769230769) # convert pixels to um
  44. properties.append(y_row / .769230769230769) # convert pixels to um
  45. properties.append(r * sqrt(2)) # compute radii in 3rd column of DataFrame
  46.  
  47. mean_intensity = ????
  48. properties.append(mean_intensity)
  49.  
  50. results.append(properties)
  51.  
  52. results = DataFrame(results, columns = ['x_coor', 'y_coor', 'radius', 'mean_intensity'])
  53. results.index = results.index + 1
  54.  
  55. print(results)
  56.  
  57.  
  58. start()
Add Comment
Please, Sign In to add comment