User Tools

Site Tools


documents:120206pyip_cooking:python_imagej_cookbook

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
documents:120206pyip_cooking:python_imagej_cookbook [2018/07/16 00:23] – [Particle Analysis] kotadocuments:120206pyip_cooking:python_imagej_cookbook [2018/12/10 23:07] – [Plugin: MiToBo h-dome transformation] kota
Line 95: Line 95:
 print op.getDirectory()+ op.getFileName() print op.getDirectory()+ op.getFileName()
 </code> </code>
 +
 +==== Getting the directory where the curently opened image is stored ====
 +<code python:1>
 +from ij import IJ
 +
 +imp = IJ.getImage()
 +print imp.getOriginalFileInfo().directory
 +</code>
 +
 +... can also be done by ''%%IJ.getDirectory("image")%%'', but with this IJ method, one cannot specify target ImagePlus object. See also the [[https://github.com/imagej/imagej1/blob/master/ij/IJ.java#L1652-L1663|source code of IJ.getDirectory]]
 +
 +Be careful not to mix with the usage of ''%%getFileInfo%%''. This does not hold directory information. 
 +
  
 ==== Regular Expression to get meta information from file name ==== ==== Regular Expression to get meta information from file name ====
Line 772: Line 785:
 imps[0].show() # Channel 1 imps[0].show() # Channel 1
 imps[1].show() # Channel 2 imps[1].show() # Channel 2
 +</code>
 +
 +==== Channel Merge ====
 +
 +[Image > Color > Merge Channels...]
 +
 +<code python linenums:1>
 +from ij import ImagePlus
 +from ij.plugin import RGBStackMerge, RGBStackConverter
 +
 +impc1 = ImagePlus("path/to/image.tif")
 +impc2 = ImagePlus("path/to/image.tif")
 +
 +mergeimp = RGBStackMerge.mergeChannels([impc2, None, impc1, None, None, None, None], True)
 +
 +# convert the composite image to the RGB image
 +RGBStackConverter.convertToRGB(mergeimp)
 +
 +mergeimp.show()
 </code> </code>
 ==== Z projection ==== ==== Z projection ====
Line 1522: Line 1554:
 cm.setPointSize(3) cm.setPointSize(3)
 </code> </code>
-===== Plugin: LOCI BioFormats, Replacing OME-TIFF XML =====+===== Plugin: LOCI BioFormats ===== 
 + 
 +==== Importing CZI file ==== 
 + 
 +<code python linenums:1> 
 +from loci.plugins import BF 
 +from loci.plugins.in import ImporterOptions 
 + 
 +filepath = "/path/to/image/my.czi" 
 + 
 +# Options for Bioformats pluginincludeing the image path 
 +options = ImporterOptions() 
 +options.setOpenAllSeries(True) 
 +options.setShowOMEXML(False) 
 +options.setStitchTiles(False) 
 +options.setId(filepath) 
 +     
 +fullimps = BF.openImagePlus(options) 
 + 
 +#fullimps now holds multiple images contained within the czi file.  
 +# open the first one.  
 +fullimps[0].show() 
 +</code> 
 + 
 +See here for more on metadata parsing and so on: [[https://gist.github.com/ctrueden/6282856|bio-formats.py]] 
 + 
 +==== Replacing OME-TIFF XML ====
  
 <code python linenums:1> <code python linenums:1>
Line 1841: Line 1899:
     print p, resmap.get(p)     print p, resmap.get(p)
 </code> </code>
 +
 +===== Plugin: MiToBo h-dome transformation =====
 +
 +h-dome is useful for spot detection in a noisy background. [[https://www.researchgate.net/publication/261206082_A_new_approach_for_spot_detection_in_total_internal_reflection_fluorescence_microscopy | For example, see this reference]]. The example here uses Plugin MiToBo, a huge collection of various components. 
 +
 +<code python>
 +from de.unihalle.informatik.MiToBo.core.datatypes.images import MTBImage
 +from de.unihalle.informatik.MiToBo.morphology import HDomeTransform3D
 +from ij import IJ
 +
 +imp = IJ.getImage()
 +mtb = MTBImage.createMTBImage( imp.duplicate() )
 +hdome = HDomeTransform3D(mtb, 10.0)
 +hdome.runOp()
 +mtbdone = hdome.getResultImage()
 +imp2 = mtbdone.getImagePlus()
 +imp2.show()
 +
 +</code>
 +
 +
 ===== R: Multi-Peak fitting using R ===== ===== R: Multi-Peak fitting using R =====
  
documents/120206pyip_cooking/python_imagej_cookbook.txt · Last modified: 2022/10/16 07:12 by kota

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki