Commit 94d29d1c authored by Lucy McNeill's avatar Lucy McNeill
Browse files

add jupyter notebook, update python script

parent 0eef1a1e
No preview for this file type
%% Cell type:code id: tags:
``` python
from nd2reader import ND2Reader
import matplotlib.pyplot as plt
import numpy as np
import os
import glob
from PIL import Image
# location of the nd2 files to convert
#parent_dir = 'data-folder/from-sharepoint/OneDrive_1_01-06-2021'
parent_dir = '/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021'
dpi_choice = 50
filenames = []
filenames_base = []
for file in glob.glob(os.path.join(parent_dir, '*nd2')):
filenames.append(file)
filenames = sorted(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)
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.tif',dpi = dpi_choice)
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(new_name)+'-MLH3.tif',dpi = dpi_choice)
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.tif', dpi = dpi_choice)
except:
print("Couldn't open file"+str(name))
```
%% Output
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image001
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image002
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image003
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image004
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image005
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image006
Couldn't open file/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image006.nd2
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image007
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image008
Couldn't open file/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image008.nd2
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image009
<ipython-input-3-596d39bad430>:30: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
plt.figure(figsize = (10,10))
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image010
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image011
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image012
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image013
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image014
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image015
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image016
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image017
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image018
/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021/20210420_fancm_fvb_exon2_595++_MLH3rabbit488_SYCP3mouse594_VT_slide01_image019
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
......@@ -6,7 +6,9 @@ import glob
from PIL import Image
# location of the nd2 files to convert
parent_dir = 'data-folder/from-sharepoint/OneDrive_1_01-02-2021'
#parent_dir = 'data-folder/from-sharepoint/OneDrive_1_01-06-2021'
parent_dir = '/Users/lmcneill/Documents/svi/imaging/data-folder/from-sharepoint/OneDrive_1_01-06-2021'
dpi_choice = 50
filenames = []
filenames_base = []
......@@ -38,7 +40,7 @@ for name in filenames:
## 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.savefig(str(new_name)+'-DAPI.tif',dpi = dpi_choice)
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
......@@ -47,7 +49,7 @@ for name in filenames:
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.savefig(str(new_name)+'-MLH3.tif',dpi = dpi_choice)
plt.figure(figsize = (10,10))
plt.gca().set_axis_off()
plt.subplots_adjust(top = 1, bottom = 0, right = 1, left = 0,
......@@ -56,7 +58,7 @@ for name in filenames:
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')
plt.savefig(str(new_name)+'-SYCP3.tif', dpi = dpi_choice)
except:
print("Couldn't open file"+str(name))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment