Acquire adjacent individual fields of view

Post your acquisition-related questions and macros here
Adrien T'Kint
Posts: 4
Joined: Fri Jun 03, 2022 10:49 am

Acquire adjacent individual fields of view

Post by Adrien T'Kint »

Dear Carl Zeiss,

I received some very nice microscopes from you -two Axio Imagers and one Axio Observer- as well as licenses of Zen Blue ranging from version 3.3 to 3.6.

I would like to modify an existing Zen experiment from my macro such that it acquires 100 laterally adjacent individual fields of view with no overlap (10 along X by 10 along Y) centered around a given X,Y,Z position. For each field of view, an image based autofocus shall be executed. Further, I would like to save each field of view in a separate file. Finally, I would also be able to access their metadata like autofocus quality, autofocus duration and Z position to control whether the object was correctly found.

Current situation
At this point, I am simply running over all positions and at each position, I run tile_image = Zen.Acquisition.Execute(experiment). The experiment has "software autofocus" as autofocus strategy.

When manually defining a Zen Tile experiment of 100 tiles (with AF for every tile), I have remarked that the duration of the acquisition was reduced by around 40% with respect to my current macro.
1) Is that in line with your expectations? How does it come? What is the best way to speed up the scanning?

This is why I am investigating scanning with a dedicated scan experiment as a Tile Region experiment or a Position experiment.

Issue faced with Tile Region experiments

My attempt with Tile Region experiments looks as follow:

Code: Select all

exp = Zen.Acquisition.Experiments.GetByName("tiles.czexp")
exp.ClearTileRegionsAndPositions(0)
exp.AddRectangleTileRegion(0,
                           region_center[0],
                           region_center[1],
                           width,
                           height,
                           region_center[2])
tile_region = Zen.Acquisition.Execute(exp)
Zen.Application.Save(tile_region, tile_region_filename)
tile_region.Close()
But the saved image is almost empty. It is 239KB and when I manually open it, I get no image to see.
The actual image is saved in temp folder of AutoSavePath of Saving tab of Tools/Options menu.
2) Can you help me properly saving a Tile region in the destination folder I choose?

When I open the image saved in the temp folder, I face another issue: I don't know how to split up the file in its individual tiles.
3) Can you help me saving the tiles of a tile region separately as individual files?

Issue faced with Positions experiments

My attempt with Positions experiments looks as follow:

Code: Select all

exp = Zen.Acquisition.Experiments.GetByName("tiles.czexp")
exp.ClearTileRegionsAndPositions(0)

for i in range(n_tiles):
    exp.AddSinglePosition(0,
                          Zen.Devices.Stage.ActualPositionX,
                          Zen.Devices.Stage.ActualPositionY + i * width_field_of_view,
                          Zen.Devices.Focus.ActualPosition)
positions_image = Zen.Acquisition.Execute(exp)

Zen.Application.Save(positions_image, positions_image_filename)
positions_image.Close()
But the saved image is almost empty as well.
The actual images are saved in temp folder of AutoSavePath of Saving tab of Tools/Options menu.
4) Can you help me properly saving the individual field of view in the destination folder I choose?

5) Furthermore, is there a way to define a grid of positions with one single Zen function?

Accessing the metadata

As mentioned above, I would like to access the metadata of the individual fields of view for quality control.
At this point, it is based on next code line.

Code: Select all

xml_metadata = image.Metadata.Xml
Is it possible to keep this requirement in mind when proposing a solution to speed up the scan?

Mit freundlichen Grüßen,
Adrien
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: Acquire adjacent individual fields of view

Post by CarlZeissMicroscopy3 »

Hello Adrien T'Kint,

this is a big one and I would like to begin with your first code snipped.

In my case

Code: Select all

exp = Zen.Acquisition.Experiments.GetByName("TestTiles.czexp")

exp.ClearTileRegionsAndPositions(0)

exp.AddRectangleTileRegion(0,100, 100, 200,200,0)

tile_region = Zen.Acquisition.Execute(exp)

#Just to see the image immediately
Zen.Application.Documents.Add(tile_region)

#Save the image directly
tile_region.Save("C:\\TEMP\\tile_region.czi")

tile_region.Close()
worked as expected and the image showed up and was saved successfully.

I hope this helps to start the discussion ...
laury friese
Posts: 1
Joined: Wed Apr 19, 2023 1:07 pm

Re: Acquire adjacent individual fields of view

Post by laury friese »

Alternately, for your case of getting the next element in a container, you can use the nextSibling or prevSibling. All components have these methods. It would be a little less walking around the DOM structure. They also allow for a selector argument. Candy Crush
julie diane
Posts: 19
Joined: Wed Jun 28, 2023 1:25 am

Re: Acquire adjacent individual fields of view

Post by julie diane »

Adrien T'Kint wrote: Wed Oct 05, 2022 4:07 pm Dear Carl Zeiss,

I received some very nice microscopes from you -two Axio Imagers and one Axio Observer- as well as licenses of Zen Blue ranging from version 3.3 to 3.6.

I would like to modify an existing Zen experiment from my macro such that it acquires 100 laterally adjacent individual fields of view with no overlap (10 along X by 10 along Y) centered around a given X,Y,Z position. For each field of view, an image based autofocus shall be executed. Further, I would like to save each field of view in a separate file. Finally, I would also be able to access their metadata like autofocus quality, autofocus duration and Z position to control whether the object was correctly found.

Current situation
At this point, I am simply running over all positions and at each position, I run tile_image = Zen.Acquisition.Execute(experiment). The experiment has "software autofocus" as autofocus strategy.

When manually defining a Zen Tile experiment of 100 tiles (with AF for every tile), I have remarked that the duration of the acquisition was reduced by around 40% with respect to my current macro.
1) Is that in line with your expectations? How does it come? What is the best way to speed up the scanning?

This is why I am investigating scanning with a dedicated scan experiment as a Tile Region experiment or a Position experiment.

Issue faced with Tile Region experiments

My attempt with Tile Region experiments looks as follow:

Code: Select all

exp = Zen.Acquisition.Experiments.GetByName("tiles.czexp")
exp.ClearTileRegionsAndPositions(0)
exp.AddRectangleTileRegion(0,
                           region_center[0],
                           region_center[1],
                           width,
                           height,
                           region_center[2])
tile_region = Zen.Acquisition.Execute(exp)
Zen.Application.Save(tile_region, tile_region_filename)
tile_region.Close()
But the saved image is almost empty. It is 239KB and when I manually open it, I get no image to see.
The actual image is saved in temp folder of AutoSavePath of Saving tab of Tools/Options menu.
2) Can you help me properly saving a Tile region in the destination folder I choose?

When I open the image saved in the temp folder, I face another issue: I don't know how to split up the file in its individual tiles.
3) Can you help me saving the tiles of a tile region separately as individual files?

Issue faced with Positions experiments

My attempt with Positions experiments looks as follow:

Code: Select all

exp = Zen.Acquisition.Experiments.GetByName("tiles.czexp")
exp.ClearTileRegionsAndPositions(0)

for i in range(n_tiles):
    exp.AddSinglePosition(0,
                          Zen.Devices.Stage.ActualPositionX,
                          Zen.Devices.Stage.ActualPositionY + i * width_field_of_view,
                          Zen.Devices.Focus.ActualPosition)
positions_image = Zen.Acquisition.Execute(exp)

Zen.Application.Save(positions_image, positions_image_filename)
positions_image.Close()
But the saved image is almost empty as well.
The actual images are saved in temp folder of AutoSavePath of Saving tab of Tools/Options menu.
4) Can you help me properly saving the individual field of view in the destination folder I choose?

5) Furthermore, is there a way to define a grid of positions with one single Zen function?

Accessing the metadata

As mentioned above, I would like to access the metadata of the individual fields of view for quality control.
At this point, it is based on next code line.

Code: Select all

xml_metadata = image.Metadata.Xml
Is it possible to keep this requirement in mind when proposing a solution to speed up the scan?

Mit freundlichen Grüßen,
Adrien
Hello,

It's great to hear that you received the microscopes and licenses, and you're working on optimizing your imaging experiments in Zen Blue. Let's address your questions and concerns one by one:

Speeding up the scanning: The observation that a manually defined Zen Tile experiment with 100 tiles and autofocus for each tile was faster than your current macro could be due to the internal optimizations Zen Blue applies to its predefined tile scanning. To speed up your macro, you can try reducing unnecessary delays, optimizing autofocus settings, and minimizing other processing steps. Additionally, using dedicated scan experiments like Tile Region or Position experiments, as you've explored, can potentially provide better performance.

Saving Tile Region in a chosen destination folder: To save the Tile Region image in your desired location, you can use the SaveAs() method instead of Save() and specify the destination path. Here's an example:

python
Copy code
tile_region.SaveAs("C:\\Your\\Destination\\Path\\filename.czi")
Saving individual tiles of a Tile Region separately: To save individual tiles as separate files, you can use the SaveAs() method on each tile. Here's a sample code to achieve that:
python
Copy code
for i in range(tile_region.NumberOfTiles):
tile = tile_region.GetTile(i)
tile.SaveAs(f"C:\\Your\\Destination\\Path\\Tile_{i}.czi")
Saving individual fields of view from Positions experiment https://stripesroofing.com: Similar to saving tiles, you can save individual fields of view from a Positions experiment using the SaveAs() method on each position image.
python
Copy code
for i in range(n_tiles):
position_image = positions_image.GetPosition(i)
position_image.SaveAs(f"C:\\Your\\Destination\\Path\\Position_{i}.czi")
Defining a grid of positions with one Zen function: You can define a grid of positions by using nested loops to cover the desired X, Y coordinates for your fields of view.
python
Copy code
for x in range(grid_x_size):
for y in range(grid_y_size):
# Calculate X, Y, and Z positions based on the grid step and starting point
# Add positions to the experiment using exp.AddSinglePosition()
Accessing metadata: To access metadata for individual fields of view, you can continue using the image.Metadata.Xml property. This will allow you to retrieve information like autofocus quality, duration, and Z position.

python
Copy code
for i in range(n_tiles):
position_image = positions_image.GetPosition(i)
xml_metadata = position_image.Metadata.Xml
# Extract required metadata information from xml_metadata
By implementing these changes and optimizations, you should be able to speed up the scanning process while maintaining access to the desired metadata for quality control. Feel free to reach out if you have any further questions or need additional assistance. Good luck with your experiments!
Rob Harris
Posts: 2
Joined: Mon Jun 12, 2023 11:26 am

Re: Acquire adjacent individual fields of view

Post by Rob Harris »

CarlZeissMicroscopy3 wrote: Fri Oct 07, 2022 12:29 pm Hello Adrien T'Kint,

this is a big one and I would like to begin with your first code snipped.

In my case

Code: Select all

exp = Zen.Acquisition.Experiments.GetByName("TestTiles.czexp")

exp.ClearTileRegionsAndPositions(0)

exp.AddRectangleTileRegion(0,100, 100, 200,200,0)

tile_region = Zen.Acquisition.Execute(exp)

#Just to see the image immediately
Zen.Application.Documents.Add(tile_region)

#Save the image directly
tile_region.Save("C:\\TEMP\\tile_region.czi")

tile_region.Close()
worked as expected and the image showed up and was saved successfully.

I hope this helps to start the discussion ...
Huge thanks!
Meerak Official
Posts: 3
Joined: Tue Sep 26, 2023 3:01 pm

Re: Acquire adjacent individual fields of view

Post by Meerak Official »

Check the latest design of Party Wear Dress online at Meerak. We offer our customers the best quality party dresses online in all over Pakistan at great prices. So, grab your favorite dresses online today.
servis shoes
Posts: 5
Joined: Wed Sep 27, 2023 8:05 am

Re: Acquire adjacent individual fields of view

Post by servis shoes »

Buy the latest men formal shoes in all sizes with different colors at reasonable Prices. We deliver a product on COD in all over Pakistan with fast delivery.
Walkeaze Shoes
Posts: 3
Joined: Wed Sep 27, 2023 8:24 am

Re: Acquire adjacent individual fields of view

Post by Walkeaze Shoes »

Walkeaze offers its customers the best quality Slippers for women online in Pakistan. You can buy slippers online across Pakistan at great prices. So, grab your favorite women's slippers today and enjoy.
Adoro Shoes
Posts: 6
Joined: Wed Sep 27, 2023 11:27 am

Re: Acquire adjacent individual fields of view

Post by Adoro Shoes »

Step into style with our collection of ladies shoes. Our stunning range of shoes offers all the latest styles in stunning colors and designs, perfect for any occasion. Whether you're looking for a classic pump or a daring stiletto, we have the perfect pair for you. Enjoy comfortable walking and maximum support with our super comfortable sole and breathable material. Shop now and stand out from the crowd!
The Entertainer
Posts: 3
Joined: Wed Sep 27, 2023 11:39 am

Re: Acquire adjacent individual fields of view

Post by The Entertainer »

The Entertainer provides baby dolls for girls online in Pakistan. The Entertainer bring an amazing collection of baby dolls and dolls house sets for their costumer.
Post Reply