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
documents:120206pyip_cooking:python_imagej_cookbook [2022/10/16 06:37] – [Using Java8 Stream] kotadocuments:120206pyip_cooking:python_imagej_cookbook [2024/10/08 17:45] (current) – [Accessing multiple files to load image sequences] kota
Line 410: Line 410:
 </code> </code>
 ==== Accessing multiple files to load image sequences ==== ==== Accessing multiple files to load image sequences ====
 +
 +A simple way is to use glob package (file not loaded in this example).
 +<code python linenums:1>
 +import glob, os
 +from ij.io import DirectoryChooser 
 +
 +srcDir = DirectoryChooser("Choose!").getDirectory()
 +for filename in glob.glob(os.path.join(srcDir, "*.tif")):
 +print(os.path.basename(filename))
 +</code>
  
 Here is a cool script written by Christian Tischer for loading image series using file prefix as dictionary keys.  Here is a cool script written by Christian Tischer for loading image series using file prefix as dictionary keys. 
Line 789: Line 799:
 ==== Using Java8 Stream ==== ==== Using Java8 Stream ====
  
-Stream-related syntax introduced from Java8 is useful for writing clear codes, but cannot be directly used in Jython. Below is a way to use StreamAPI, by introducing Jython classes implementing the Consumer interface. I took this idea from [[https://stackoverflow.com/questions/45417732/jython-function-to-java-consumer|here]].+Stream-related syntax introduced from Java8 is useful for writing clear codes, but cannot be directly used in Jython. Below is a way to use StreamAPI, by introducing Jython classes implementing the Consumer interface. I took this idea from [[https://stackoverflow.com/questions/45417732/jython-function-to-java-consumer|here]]. For the Java Stream API, this page is useful: [[https://www.baeldung.com/java-8-streams|The Java 8 Stream API Tutorial]]
  
 <code python> <code python>
documents/120206pyip_cooking/python_imagej_cookbook.1665902270.txt.gz · Last modified: 2022/10/16 06:37 by kota

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki