Skip to content

Commit

Permalink
ome schema finished
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Perez Meza committed Sep 27, 2024
1 parent 3ef3f73 commit 8780eb3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 44 deletions.
3 changes: 2 additions & 1 deletion macsima2mc/macsima2mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import os


input_test_folder=Path("D:/macsima_data_samples/macsima_data_v2/6_Cycle1")

input_test_folder=Path("D:/macsima_data_samples/macsima_data_v2/8_Cycle2")
output_test_folder=Path('D:/test_folder')

info=helpers.cycle_info(input_test_folder, macsima_pattern(version=2),ref_marker= 'DAPI')
Expand Down
23 changes: 10 additions & 13 deletions macsima2mc/ome_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def INPUTS(frame,conformed_markers):



def TIFF_block(no_of_channels,
def TIFF_array(no_of_channels,
inputs={'offset':0}
):

Expand All @@ -42,7 +42,7 @@ def TIFF_block(no_of_channels,

return TIFF

def PLANE_block(no_of_channels,inputs):
def PLANE_array(no_of_channels,inputs):

PLANE=[
Plane(
Expand All @@ -61,7 +61,7 @@ def PLANE_block(no_of_channels,inputs):

return PLANE

def CHANN_block(no_of_channels,inputs):
def CHANN_array(no_of_channels,inputs):

CHANN=[
Channel(
Expand All @@ -78,7 +78,7 @@ def CHANN_block(no_of_channels,inputs):

return CHANN

def PIXELS_block(chann_block,plane_block,tiff_block,inputs):
def PIXELS_array(chann_block,plane_block,tiff_block,inputs):

PIXELS=[
Pixels(
Expand Down Expand Up @@ -106,21 +106,18 @@ def PIXELS_block(chann_block,plane_block,tiff_block,inputs):

return PIXELS

def IMAGE_block(no_of_tiles,
inputs={'pix_block':[]}
):
def IMAGE_array(pixels_block,imageID):

IMAGE=[
Image(
id=ome_types.model.simple_types.ImageID('Image:{x}'.format(x=t)),
pixels=inputs['pix_block'][t]
id=ome_types.model.simple_types.ImageID('Image:{x}'.format(x=imageID)),
pixels=pixels_block
)
for t in range(0,no_of_tiles)
]
]

return IMAGE

def OME_xml(inputs={'img_block':[]}):
def OME_xml(image_block):

ome=OME()
ome.creator=" ".join([ome_types.__name__,
Expand All @@ -129,7 +126,7 @@ def OME_xml(inputs={'img_block':[]}):
platform.python_version()
]
)
ome.images=inputs['img_block']
ome.images=image_block
ome.uuid=uuid4().urn
ome_xml=to_xml(ome)

Expand Down
48 changes: 18 additions & 30 deletions macsima2mc/ome_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,23 @@
def create_ome(tile_info,conformed_markers):
grouped_tiles=tile_info.groupby(['tile'])
no_of_channels=len(conformed_markers)

tiles_counter=0
image=[]
for tileID,frame in grouped_tiles:
for marker,filter in conformed_markers:
metadata=frame.loc[ (frame['marker']==marker) & (frame['filter']==filter) ]
metadata.position_x.values[0]


tiff=schema.TIFF_block(no_of_channels,
inputs={'offset':n*no_of_channels}
)
plane=schema.PLANE_block(no_of_channels,
inputs={'position_x':0,'position_x_unit':'','position_y':0,'position_y_unit':'','exposure_time':[]}
)
ch=schema.CHANN_block()


a=[schema.IMAGE_block(

schema.PIXELS_block( inputs={'tile_id':0,'size_x':0,'size_y':0,'type':'',
'chann_block':[],'pix_size_x':0,'pix_size_y':0,
'pix_size_x_units':'','pix_size_y_units':'',
'plane_block':[],'sig_bits':0,'tiff_block':[]
}

}

)


)]

metadata=schema.INPUTS(frame, conformed_markers)
tiff=schema.TIFF_array( no_of_channels, inputs={'offset':no_of_channels*tiles_counter} )
plane=schema.PLANE_array(no_of_channels, metadata)
channel=schema.CHANN_array(no_of_channels,metadata)
image.append( schema.IMAGE_array (
schema.PIXELS_array(channel,plane,tiff,metadata),
tiles_counter
)
)
tiles_counter=+1

ome_xml=schema.OME_xml(image)

return ome_xml



0 comments on commit 8780eb3

Please sign in to comment.