Skip to content
Snippets Groups Projects
Commit 0c232da8 authored by Lucy McNeill's avatar Lucy McNeill
Browse files

nd2 converter names files with antibody

parent fcc55711
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -5,46 +5,58 @@ import os
import glob
from PIL import Image
parent_dir = 'data-folder/sharepoint'
# location of the nd2 files to convert
parent_dir = 'data-folder/from-sharepoint/OneDrive_1_01-02-2021'
filenames = []
filenames_base = []
for file in glob.glob(os.path.join(parent_dir, '*nd2')):
filenames.append(file)
filenames = sorted(filenames)
print(filenames)
for name in filenames:
base=os.path.basename(name)
os.path.splitext(base)
name_base = os.path.splitext(base)[0]
new_name = parent_dir+'/'+str(name_base)
print(new_name)
with ND2Reader(str(name)) as images:
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[0],cmap = 'gray')
### keep metadata... e.g.
## savefig(fname, dpi=None, facecolor='w', edgecolor='w',
## orientation='portrait', papertype=None, format=None,
## transparent=False, bbox_inches=None, pad_inches=0.1,
## frameon=None, metadata=None)
plt.savefig(str(name)+'cells.jpeg')
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[1],cmap = 'gray')
plt.savefig(str(name)+'foci.jpeg')
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
try:
with ND2Reader(str(name)) as images:
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[0],cmap = 'gray')
### keep metadata... e.g.
## savefig(fname, dpi=None, facecolor='w', edgecolor='w',
## orientation='portrait', papertype=None, format=None,
## transparent=False, bbox_inches=None, pad_inches=0.1,
## frameon=None, metadata=None)
plt.savefig(str(new_name)+'-DAPI.jpeg')
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[2],cmap = 'gray')
plt.savefig(str(name)+'dna.jpeg')
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[1],cmap = 'gray')
plt.savefig(str(new_name)+'-MLH3.jpeg')
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
hspace = 0, wspace = 0)
plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[2],cmap = 'gray')
plt.savefig(str(new_name)+'-SYCP3.jpeg')
except:
print("Couldn't open file"+str(name))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment