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 ...@@ -5,46 +5,58 @@ import os
import glob import glob
from PIL import Image 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 = []
filenames_base = []
for file in glob.glob(os.path.join(parent_dir, '*nd2')): for file in glob.glob(os.path.join(parent_dir, '*nd2')):
filenames.append(file) filenames.append(file)
filenames = sorted(filenames) filenames = sorted(filenames)
print(filenames)
for name in 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: try:
plt.figure(figsize = (10,10))
plt.gca().set_axis_off() with ND2Reader(str(name)) as images:
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, plt.figure(figsize = (10,10))
hspace = 0, wspace = 0) plt.gca().set_axis_off()
plt.margins(0,0) plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
plt.gca().xaxis.set_major_locator(plt.NullLocator()) hspace = 0, wspace = 0)
plt.gca().yaxis.set_major_locator(plt.NullLocator()) plt.margins(0,0)
plt.imshow(images[0],cmap = 'gray') plt.gca().xaxis.set_major_locator(plt.NullLocator())
### keep metadata... e.g. plt.gca().yaxis.set_major_locator(plt.NullLocator())
## savefig(fname, dpi=None, facecolor='w', edgecolor='w', plt.imshow(images[0],cmap = 'gray')
## orientation='portrait', papertype=None, format=None, ### keep metadata... e.g.
## transparent=False, bbox_inches=None, pad_inches=0.1, ## savefig(fname, dpi=None, facecolor='w', edgecolor='w',
## frameon=None, metadata=None) ## orientation='portrait', papertype=None, format=None,
plt.savefig(str(name)+'cells.jpeg') ## transparent=False, bbox_inches=None, pad_inches=0.1,
plt.figure(figsize = (10,10)) ## frameon=None, metadata=None)
plt.gca().set_axis_off() plt.savefig(str(new_name)+'-DAPI.jpeg')
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0, plt.figure(figsize = (10,10))
hspace = 0, wspace = 0) plt.gca().set_axis_off()
plt.margins(0,0) plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 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,
hspace = 0, wspace = 0) hspace = 0, wspace = 0)
plt.margins(0,0) plt.margins(0,0)
plt.gca().xaxis.set_major_locator(plt.NullLocator()) plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator()) plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.imshow(images[2],cmap = 'gray') plt.imshow(images[1],cmap = 'gray')
plt.savefig(str(name)+'dna.jpeg') 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