コード例 #1
0
def open_image(username, password, host, server_port, group_id, image_id):
    command="location=[OMERO] open=[omero:"
    command+="server=%s\n" % server
    command+="user=%s\n" % username
    command+="port=%s\n" % server_port
    command+="pass=%s\n" % password
    if group_id > -1:
		command+="groupID=%s\n" % group_id
    command+="iid=%s] " % image_id
    command+="windowless=true "
    command+="splitWindows=false "
    command+="color_mode=Default view=[%s] stack_order=Default" % ImporterOptions.VIEW_HYPERSTACK
    print "Opening image: id", image_id 
    IJ.runPlugIn("loci.plugins.LociImporter", command)
    imp = IJ.getImage()
    return imp
コード例 #2
0
def openImagePlus(HOST,USERNAME,PASSWORD,groupId,imageId):
    
    options = ""
        options += "location=[OMERO] open=[omero:server="
        options += HOST
        options += "\nuser="******"\npass="******"\ngroupID="
        options += groupId
        options += "\niid="
        options += imageId
        options += "]"
        options += " windowless=true "
        
        IJ.runPlugIn("loci.plugins.LociImporter", options);
コード例 #3
0
def open_image_plus(host, username, password, group_id, image_id):

    options = ""
    options += "location=[OMERO] open=[omero:server="
    options += host
    options += "\nuser="******"\npass="******"\ngroupID="
    options += String.valueOf(group_id)
    options += "\niid="
    options += String.valueOf(image_id)
    options += "]"
    options += " windowless=true "

    IJ.runPlugIn("loci.plugins.LociImporter", options)
コード例 #4
0
def openImagePlus(HOST,USERNAME,PASSWORD,groupId,imageId):
    
    options = ""
    options += "location=[OMERO] open=[omero:server="
    options += HOST
    options += "\nuser="******"\npass="******"\ngroupID="
    options += str(groupId)
    options += "\niid="
    options += imageId
    options += "]"
    options += " windowless=true "
    
    IJ.runPlugIn("loci.plugins.LociImporter", options);
コード例 #5
0
from ij import IJ
IJ.runPlugIn("ij.plugin.BrowserLauncher", "http://www.nitrc.org/projects/cmtk/");
コード例 #6
0
from ij import IJ
IJ.runPlugIn("ij.plugin.BrowserLauncher", "http://www.nitrc.org/forum/forum.php?forum_id=857")
コード例 #7
0
ファイル: About_CMTK.py プロジェクト: jefferis/fiji-cmtk-gui
from ij.gui import GenericDialog

import sys
from java.lang.System import getProperty
sys.path.append(getProperty("fiji.dir") + "/plugins/CMTK_Registration")

gd = GenericDialog('About CMTK')
gd.addMessage('CMTK Registration suite is open source software released under GPLv3',)
gd.addMessage('Currently installed CMTK version: '+cmtkgui.installed_version())
gd.addMessage('CMTK binary directory: '+cmtkgui.bin_dir())
gd.setCancelLabel("CMTK Web Page")
gd.showDialog()
if gd.wasCanceled():
	from ij import IJ
	IJ.runPlugIn("ij.plugin.BrowserLauncher", "http://www.nitrc.org/projects/cmtk/")
コード例 #8
0
from ij import IJ
IJ.runPlugIn("ij.plugin.BrowserLauncher", "http://www.nitrc.org/docman/view.php/212/708/UserGuideCMTK.pdf")
コード例 #9
0
from ij import IJ
IJ.runPlugIn("ij.plugin.BrowserLauncher", "http://www.nitrc.org/docman/?group_id=212");
コード例 #10
0
def process_imgdir( directory, close_after ) :
    print( 'Processing: ' + directory )

    original_image_filename = directory + '/uniform.tif'
    probabilities_image_filename = directory + '/probabilities.tif'
    cube_rois_filename = directory + '/CubeROIs.csv'

    cubes = []
    f = open(cube_rois_filename)
    lines = f.readlines()
    for line in lines[1:]:
        #els = [ int(el)-1 for el in line.strip().split(',') ]
        els = [ int(el) for el in line.strip().split(',') ]
        cubes += [ { 'idx': els[0], 'class': els[1], 'x1':min(els[2],els[5]), 'y1':min(els[3],els[6]), 'z1':min(els[4],els[7]), 'x2':max(els[5],els[2]), 'y2':max(els[6],els[3]), 'z2':max(els[4],els[7]) } ]
    f.close()
    print( 'Read ' + str(len(cubes)) + ' cubes from file' )

    #for cube in cubes:
    #for cube_idx in range( len( cubes ) ):
    for cube_idx in [0]:
        cube = cubes[cube_idx]
        print( cube )

        all_edt_histograms['name'] += [ directory.split( '/' )[-1] + '_' + str(cube_idx) ]
        all_skeleton_edt_histograms['name'] += [ directory.split( '/' )[-1] + '_' + str(cube_idx) ]

        cube_basename = directory + '/cube_' + str(cube_idx) + '_'

        # Check if we have a parameters file, and evaluate it if so, otherwise make one with defaults
        param_filename = cube_basename + 'parameters.py'
        # Make a default to start with
        no_params_set = False
        if not os.path.isfile( param_filename ):
            f = open( param_filename, 'w' )
            f.write( 'mesh_thresh=200\n' )
            f.write( 'interior_coords=[ (1,1,1) ]\n' )
            f.close()
            no_params_set = True

        if os.path.isfile( param_filename ):
            f = open( param_filename )
            lines = f.readlines()
            for line in lines:
                if 'mesh_thresh' in line:
                    mesh_thresh = eval(line.split('=')[1])
                if 'interior_coords' in line:
                    interior_coords = eval(line.split('=')[1])

        load_uniform = True
        if load_uniform:
            #open uniform
            uniform = IJ.openImage( original_image_filename )

            #crop uniform
            uniform.setRoi( cube['x1'], cube['y1'], cube['x2'], cube['y2'] )
            IJ.run( uniform, "Crop", "")
            IJ.run( uniform, "Make Substack...", "slices=" + str(cube['z1']) + '-' + str(cube['z2']) )
            uniform.close()
            uniform = IJ.getImage()
            IJ.saveAsTiff( uniform, cube_basename + 'raw.tif' )

            #save max_projection of uniform
            IJ.run(uniform, "Z Project...", "projection=[Max Intensity]")
            uniform_mp = IJ.getImage()
            IJ.run(uniform_mp, "Enhance Contrast", "saturated=0.35")
            IJ.saveAsTiff( uniform_mp, cube_basename + 'raw_maxproj.tif' )

        #open probabilites
        probabilities = IJ.openImage( probabilities_image_filename )

        #crop probabilites
        probabilities.setRoi( cube['x1'], cube['y1'], cube['x2'], cube['y2'] )
        IJ.run( probabilities, "Crop", "")
        IJ.run( probabilities, "Make Substack...", "slices=" + str(cube['z1']) + '-' + str(cube['z2']) )
        time.sleep( 5 )
        probabilities.close()
        probabilities = IJ.getImage()
        #IJ.saveAsTiff( probabilities, cube_basename + 'probabilities.tif' )

        time.sleep( 5 )

        #save max_projection of probabilites
        IJ.run(probabilities, "Z Project...", "projection=[Max Intensity]")
        probabilities_mp = IJ.getImage()
        IJ.run(probabilities_mp, "Enhance Contrast", "saturated=0.35")
        IJ.saveAsTiff( probabilities_mp, cube_basename + 'probabilities_maxproj.tif' )

        time.sleep( 5 )

        # blur probabilities to help smooth the isosurfaces
        blur_radius = 2
        IJ.run( probabilities, "Gaussian Blur 3D...", 'x=' + str(blur_radius) + ' y=' + str(blur_radius) + ' z=' + str(blur_radius) )

        #threshold probabilities
        #IJ.run(probabilities, "Enhance Contrast", "saturated=0.35")
        IJ.run( probabilities, "8-bit", "")
        #IJ.saveAsTiff( probabilities, cube_basename + 'probabilities.tif' )
        #for k in range( probabilities.getNSlices() ):
        #    probabilities.setSlice(k+1)
        #    probabilities.getProcessor().setThreshold( mesh_thresh - 1, mesh_thresh + 1, 0 )
        #IJ.run( probabilities, 'Convert to Mask', 'method=Default background=Dark black')
        #time.sleep( 5 )
        IJ.saveAsTiff( probabilities, cube_basename + 'probabilities.tif' )

        time.sleep( 5 )

        #mesh binary_probabilities
        #IJ.run( "3D Viewer", "")


        threedType = 2
        threedName = 'cube_' + str(cube_idx)

        IJ.runPlugIn( "ij3d.ImageJ3DViewer", probabilities.getTitle() )
        univ = Image3DUniverse.universes.get(0)
        univ.addContent( probabilities, Color3f(1,1,1), threedName, mesh_thresh, [True, False, False], 2, threedType )
        ImageJ3DViewer.select( threedName )
        ImageJ3DViewer.exportContent( 'wavefront', cube_basename + 'mesh.obj' )

        #smooth mesh
        c = univ.getSelected()
        n = c.getContent()
        ctm = n.getMesh()
        fim = customnode.FullInfoMesh( ctm.getMesh() )
        ec = customnode.EdgeContraction( fim, False )

        initial_num_verts = ec.getVertexCount()
        num_to_remove = int( initial_num_verts * 0.1 )

        #v = InteractiveMeshDecimation.simplify( ec, num_to_remove )

        enable_smoothing = False
        if enable_smoothing:
            part = num_to_remove / 10
            last = num_to_remove % 10
            ret = 0
            for i in range(10):
                IJ.showProgress(i + 1, 10)
                ret = ec.removeNext(part)
            if (last != 0):
                ret = ec.removeNext(last)
            IJ.showProgress(1)

            ctm.setMesh( fim.getMesh() )
            ImageJ3DViewer.exportContent( 'wavefront', cube_basename + 'smooth_mesh.obj' )

        # 3d viewer screenshot
        screenshot_3d = univ.takeSnapshot()
        IJ.saveAsTiff( screenshot_3d, cube_basename + 'mesh_screenshot.tif' )

        #voxelize mesh
        voxelizer = InteractiveMeshVoxelization()
        voxelizer.voxelize( ctm, probabilities.getWidth(), probabilities.getHeight(), probabilities.getStackSize() )

        #voxelization = WindowManager.getImage( ctm.getName() + '_voxelization' )
        voxelization = WindowManager.getImage( 'null_voxelization' )
        voxelization.setCalibration( probabilities.getCalibration().copy() )
        #manually 3D fill vasculature, fill with thresholdable-color
        #save selected vasculature

        #call('process3d.Flood_Fill.fill', x,y,z)
        if not no_params_set:
            fill_color = 100
            Flood_Fill.fill( voxelization, interior_coords[0][0], interior_coords[0][1], interior_coords[0][2], fill_color )

            # Threshold to extract
            #IJ.setAutoThreshold( voxelization, 'Default dark' )
            #Prefs.blackBackground = true
            #IJ.run( voxelization, 'Convert to Mask', 'method=Default background=Dark black')

            for k in range( voxelization.getNSlices() ):
                voxelization.setSlice(k+1)
                voxelization.getProcessor().setThreshold( fill_color - 1, fill_color + 1, 0 )
            IJ.run( voxelization, 'Convert to Mask', 'method=Default background=Dark black')
            IJ.saveAsTiff( voxelization, cube_basename + 'voxelization.tif' )

            # Calculate and record volume HERE

            IJ.run(voxelization, "Z Project...", "projection=[Max Intensity]")
            voxelization_mp = IJ.getImage()
            IJ.run(voxelization_mp, "Enhance Contrast", "saturated=0.35")
            IJ.saveAsTiff( voxelization_mp, cube_basename + 'voxelization_maxproj.tif' )

            # Calculate EDT
            IJ.run( voxelization, "Exact Euclidean Distance Transform (3D)", "" )
            edt = WindowManager.getImage( 'EDT' )
            IJ.run( edt, 'Fire', '' )

            # Get the histogram data in an array

            hist_nBins = int( ( hist_max - hist_min ) / hist_step )
            #edt_stats = edt.getStatistics( Measurements.MEDIAN, hist_nBins, hist_min, hist_max )
            edt_stats = StackStatistics( edt, hist_nBins, hist_min, hist_max )
            hist_data = edt_stats.getHistogram()
            hist_binLabels = [ ( hist_min + hist_step * el ) for el in range( hist_nBins ) ]

            max_radius = 20
            IJ.run( edt, 'Histogram', 'bins=' + str(hist_nBins) + ' x_min=' + str(hist_min) + ' x_max=' + str(hist_max) + ' y_max=Auto stack' )
            edt_histogram = WindowManager.getImage( 'Histogram of EDT' )
            IJ.saveAsTiff( edt_histogram, cube_basename + 'edt_histogram.tif' )

            x_unit_scale = uniform.getCalibration().getX(1)
            y_unit_scale = uniform.getCalibration().getY(1)
            z_unit_scale = uniform.getCalibration().getZ(1)

            f = open( cube_basename + 'edt_histogram.csv', 'w' )
            for k in range( len( hist_data ) ):
                f.write( str(hist_binLabels[k]) + '\t' + str(hist_data[k]*x_unit_scale*y_unit_scale*z_unit_scale) + '\n' )
                #f.write( str(hist_binLabels[k]) + '\t' + str(hist_data[k]) + '\n' )
                all_edt_histograms[hist_binLabels[k]] += [ hist_data[k] ]

            f.close()

            # Handling skeletons
            IJ.run( voxelization, "Skeletonize (2D/3D)", "")
            skeleton = voxelization # For simplicity later, but note that voxelization has been mutated
            IJ.run(skeleton, "32-bit", "")
            IJ.run(skeleton, "Calculator Plus", 'i1=' + str(skeleton.getTitle()) + ' i2=' + str(skeleton.getTitle()) + ' operation=[Scale: i2 = i1 x k1 + k2] k1=0.003921568627 k2=0' )

            IJ.run(skeleton, "Z Project...", "projection=[Max Intensity]")
            skeleton_mp = IJ.getImage()
            IJ.run(skeleton_mp, "Enhance Contrast", "saturated=0.35")
            IJ.saveAsTiff( skeleton_mp, cube_basename + 'skeleton_maxproj.tif' )

            ic = ImageCalculator()
            skeleton_edt = ic.run("Multiply 32-bit stack", edt, skeleton)
            IJ.run( skeleton_edt, 'Fire', '' )


            # Get the histogram data in an array
            hist_nBins = int( ( hist_max - hist_min ) / hist_step )
            #skeleton_edt_stats = edt.getStatistics( Measurements.MEDIAN, hist_nBins, hist_min, hist_max )
            skeleton_edt_stats = StackStatistics( edt, hist_nBins, hist_min, hist_max )
            hist_data = skeleton_edt_stats.getHistogram()
            hist_binLabels = [ ( hist_min + hist_step * el ) for el in range( hist_nBins ) ]

            IJ.run( skeleton_edt, 'Histogram', 'bins=' + str(hist_nBins) + ' x_min=' + str(hist_min) + ' x_max=' + str(hist_max) + ' y_max=Auto stack' )
            skeleton_edt_histogram = WindowManager.getImage( 'Histogram of EDT' )
            IJ.saveAsTiff( skeleton_edt_histogram, cube_basename + 'skeleton_edt_histogram.tif' )

            unit_scale = uniform.getCalibration().getX(1)

            f = open( cube_basename + 'skeleton_edt_histogram.csv', 'w' )
            for k in range( len( hist_data ) ):
                f.write( str(hist_binLabels[k]) + '\t' + str(hist_data[k] * unit_scale) + '\n' )
                all_skeleton_edt_histograms[hist_binLabels[k]] += [ hist_data[k] * unit_scale ]
            f.close()

        else:
            IJ.saveAsTiff( voxelization, cube_basename + 'voxelization.tif' )

        # Free up resources
        if close_after:
            ImageJ3DViewer.close()
            IJ.run( 'Close All', '' )
            IJ.freeMemory()
コード例 #11
0
# ----------  --- ------  -------------------------------------------------
# 2014-10-15  JRM 0.1.00  Get'er done

from org.python.core import codecs
codecs.setDefaultEncoding('utf-8')

from ij import IJ
from ij import Macro
from java.lang import Thread

# Prepare options for Bandpass filter
options = "filter_large=40 filter_small=3 suppress=None tolerance=5 autoscale saturate"
# Get the current thread
thread = Thread.currentThread()
original_name = thread.getName()
# Rename current thread
thread.setName("Run$_my_batch_process")
# Set the options for the current thread
Macro.setOptions(Thread.currentThread(), options)

# Get the current image
imp = IJ.getImage();
# Finally, run the bandpass filter without dialogs:
IJ.runPlugIn(imp, "ij.plugin.filter.FFTFilter", "")

# Be nice: undo naming, so other scripts may run with dialogs
thread.setName(original_name);
# Be safe: remove the thread's options from the table
# (which also removes the reference to the thread itself)
Macro.setOptions(thread, None)
コード例 #12
0
from ij.gui import GenericDialog

import sys
from java.lang.System import getProperty
sys.path.append(getProperty("fiji.dir") + "/plugins/CMTK_Registration")

gd = GenericDialog('About CMTK GUI')
gd.addMessage('CMTK GUI is open source software released under GPLv3')
gd.addMessage('CMTK GUI is independently developed by Greg Jefferis and is NOT supported by CMTK team')
gd.setCancelLabel("CMTK GUI Web Page")
gd.showDialog()
if gd.wasCanceled():
	from ij import IJ
	IJ.runPlugIn("ij.plugin.BrowserLauncher", "https://github.com/jefferis/fiji-cmtk-gui")
コード例 #13
0
ファイル: Omero_Image_Download.py プロジェクト: ksiller/omero
# @ String (label="Omero User") user
# @ String (label="Omero Password", style="password") pwd
# @ String (label="Omero Server", value="omero.hpc.virginia.edu") server
# @ Integer (label="Omero Port", value=4064) port
# @ Integer (label="Omero Group ID", min=-1, value=53) omero_group_id
# @ Integer (label="Image ID", value=2014) image_id

from ij import IJ
from loci.plugins.in import ImporterOptions
	 
# Main code
command="location=[OMERO] open=[omero:"
command+="server=%s\n" % server
command+="user=%s\n" % user
command+="port=%s\n" % port
command+="pass=%s\n" % pwd
if omero_group_id > -1:
	command+="groupID=%s\n" % omero_group_id
command+="iid=%s] " % image_id
command+="windowless=true view=\'%s\' " % ImporterOptions.VIEW_HYPERSTACK
IJ.runPlugIn("loci.plugins.LociImporter", command)
コード例 #14
0
from ij import IJ

IJ.runPlugIn("ij.plugin.BrowserLauncher",
             "http://www.nitrc.org/forum/forum.php?forum_id=857")
コード例 #15
0
ファイル: fijitest.py プロジェクト: yz26a19/HoloPyGuy
def natural_keys(text):
    return [ atoi(c) for c in re.split('(\d+)', text) ]

os.chdir(mypath)
alist = os.listdir(mypath)
alist.sort(key=natural_keys)

imp = IJ.openImage(mypath + alist[0])
signedpix = imp.getProcessor().toFloat(1, None)
width=signedpix.getWidth()
height=signedpix.getHeight()
stack = ImageStack(width, height)
i=0


for file in alist[:10]:
	print("Current File Being Processed is: " + file)
	imp = IJ.openImage(mypath + file)
	signedpix = imp.getProcessor().toFloat(1, None)
	stack.addSlice(str(i), signedpix)
	i = i + 1

imp = ImagePlus("", stack)
ImageConverter(imp).convertToGray8()
imp.show()  

IJ.runPlugIn("ij3d.ImageJ3DViewer", "")


コード例 #16
0
from ij import IJ

IJ.runPlugIn("ij.plugin.BrowserLauncher",
             "http://www.nitrc.org/docman/?group_id=212")
コード例 #17
0
from ij import IJ
import jmFijiGen as jmg
import InvertGray8


# gitDir  = os.environ['GIT_HOME']
# relImg  = "/OSImageAnalysis/images"
# strImg  = gitDir + relImg + "/bridge.gif"
# strImg  = gitDir + relImg + "/latex.tif"
imgDir  = os.environ['IMG_ROOT']



strImg  = imgDir + "/key-test/KMAG/KMag1500Sei.tif"
print(strImg)

# 1. Open an image 
imp =  IJ.openImage(strImg)
imp.show()
# IJ.runPlugIn(imp, "ij.plugin.PNG_Writer", "/Users/jrminter/Desktop/Kmag1500Sei.png"

ip = imp.getProcessor()
IJ.runPlugIn("fiji.InvertGray8", imp);

IJ.runPlugIn("ij.plugin.PNG_Writer", "/Users/jrminter/Desktop/Kmag1500Sei.png")
# IJ.runPlugIn("fiji.InvertGray8", ip);
# print("dir out")
# print(out)
# res = InvertGray8()
# imp.show()
# IJ.runPlugIn(imp, "ij.plugin.PNG_Writer", "/Users/jrminter/Desktop/Kmag1500SeiInv.png")
コード例 #18
0
from ij.gui import GenericDialog

import sys
from java.lang.System import getProperty
sys.path.append(getProperty("fiji.dir") + "/plugins/CMTK_Registration")

gd = GenericDialog('About CMTK GUI')
gd.addMessage('CMTK GUI is open source software released under GPLv3')
gd.addMessage(
    'CMTK GUI is independently developed by Greg Jefferis and is NOT supported by CMTK team'
)
gd.setCancelLabel("CMTK GUI Web Page")
gd.showDialog()
if gd.wasCanceled():
    from ij import IJ
    IJ.runPlugIn("ij.plugin.BrowserLauncher",
                 "https://github.com/jefferis/fiji-cmtk-gui")