Skip to content
Snippets Groups Projects
Commit 5dc1e914 authored by Hugo chauvet's avatar Hugo chauvet
Browse files

fix MM1 version bugs in image order

parent 18dba18f
Branches
No related tags found
1 merge request!3Dev
......@@ -45,7 +45,7 @@ except:
finally:
from utils.IJmmlib import load_mm_images
from utils.mmlib import load_metadata, get_mm2_first_image_metadata, get_dimensions
from utils.mmlib import load_metadata, get_mm2_first_image_metadata, get_mm1_first_image_metadata, get_dimensions, get_micromanager_version
# Import to do operation with ImageJ2 and ImgMath
from net.imglib2.util import Intervals
......@@ -68,8 +68,8 @@ def getMMversion(metadata):
"""
Get MM version from metadata
"""
if int(metadata['Summary']["MicroManagerVersion"].split('.')[0]) >= 2:
mmversion = get_micromanager_version(metadata)
if mmversion[0] == '2':
version = 2
else:
version = 1
......@@ -345,7 +345,8 @@ def process_tiles(implus_tiles_stack, channel, z, implus_white_corr, implus_dark
dark = Views.hyperSlice(dark, 2, channel)
# Need to apply crop on dark
roi = getRoi(metadata)
mmversion = getMMversion(metadata)
roi = getRoi(metadata, mmversion)
if roi is not None and len(roi) == 4 and implus_dark_stack.width > roi[2] and implus_dark_stack.height > roi[3]:
xmin, ymin, xmax, ymax = roi
xmax = xmin + xmax
......@@ -734,11 +735,18 @@ def extract_tile_positions(metadata, selected_roi, tilesondisk, tilename='tile_'
xt, yt = getMMtiles(metadata, selected_roi, tilesondisk)
# Is the microscope use Andor camera ? (tilted at 90)
ANDOR = False
mmversion = getMMversion(metadata)
if mmversion == 2:
fmeta = get_mm2_first_image_metadata(metadata)
if fmeta['Camera'] == 'Andor':
ANDOR = True
else:
ANDOR = False
fmeta = get_mm1_first_image_metadata(metadata)
if fmeta['Core-Camera'] == 'Andor':
ANDOR = True
if ANDOR:
xtmp = yt
......
......@@ -4,7 +4,7 @@ Usefull jython functions for micro manager and imagej
"""
import os
from ij import ImagePlus, VirtualStack, IJ
from mmlib import generate_file_list, load_metadata, get_dimensions, get_resolution
from mmlib import generate_file_list, load_metadata, get_dimensions, get_resolution, get_micromanager_version
def load_mm_images(rootdir, roi=1, tile=True, pos=False,
......@@ -15,8 +15,14 @@ def load_mm_images(rootdir, roi=1, tile=True, pos=False,
"""
metadata = load_metadata(rootdir)
mmversion = int(get_micromanager_version(metadata)[0])
dimensions = get_dimensions(metadata)
image_files = generate_file_list(metadata, roi, tile, pos)
if mmversion == 1:
stack_order = ['position', 'z', 'time', 'channels']
else:
stack_order = ['position', 'time', 'channels', 'z']
image_files = generate_file_list(metadata, roi, tile, pos, stack_order)
# Create the virtual stack
vstack = VirtualStack(dimensions['width'], dimensions['height'], None, rootdir)
......
......@@ -63,6 +63,30 @@ def get_mm2_first_image_metadata(metadata):
return None
def get_mm1_first_image_metadata(metadata):
"""
Return the first metadata in the list of images starting with Metadata
"""
for k in metadata.keys():
if k.startswith('FrameKey-'):
return metadata[k]
return None
def get_mm_first_image_metadata(metadata):
"""
Return the first metadata in the list of images starting with Metadata
"""
v = get_micromanager_version(metadata)
if v[0] == '1':
return get_mm1_first_image_metadata(metadata)
return get_mm2_first_image_metadata(metadata)
def get_dimensions(metadata):
"""
Extract from metadata the dimensions of data and export a consistent
......@@ -145,7 +169,7 @@ def get_stage_positions_labels(metadata):
return stage_label
def generate_file_list(metadata, roi=1, tile=True, pos=False):
def generate_file_list(metadata, roi=1, tile=True, pos=False, stack_order=None):
"""
Generate a list of all images to load from the metadata
......@@ -178,7 +202,7 @@ def generate_file_list(metadata, roi=1, tile=True, pos=False):
pre_folder = 'Default'
# Get the combination of all conditions of acquisitions
all_conditions, ordered_keys = groups_dimensions(metadata)
all_conditions, ordered_keys = groups_dimensions(metadata, stack_order)
# Loop over conditions to create the correct file name
image_files = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment