Esempio n. 1
0
    def setscale(imp,
                 scaleX=1.0,
                 scaleY=1.0,
                 scaleZ=1.0,
                 unit="micron"):

        # check if scaleZ has a valid value to call modify the scaling
        if scaleZ is None:
            scaleZ = 1.0

        # create new Calibration object
        newCal = Calibration()

        # set the new paramters
        newCal.pixelWidth = scaleX
        newCal.pixelHeight = scaleY
        newCal.pixelDepth = scaleZ

        # set the correct unit fro the scaling
        newCal.setXUnit(unit)
        newCal.setYUnit(unit)
        newCal.setZUnit(unit)

        # apply the new calibration
        imp.setCalibration(newCal)

        return imp
Esempio n. 2
0
    def setproperties(imp,
                      scaleX=1.0,
                      scaleY=1.0,
                      scaleZ=1.0,
                      unit="micron",
                      sizeC=1,
                      sizeZ=1,
                      sizeT=1):
        """Set properties of image in Fiji

        :param imp: Image
        :type imp: ImgPlus
        :param scaleX: scaleX, defaults to 1.0
        :type scaleX: float, optional
        :param scaleY: scaleY, defaults to 1.0
        :type scaleY: float, optional
        :param scaleZ: scaleZ, defaults to 1.0
        :type scaleZ: float, optional
        :param unit: scale unit, defaults to "micron"
        :type unit: str, optional
        :param sizeC: sizeC, defaults to 1
        :type sizeC: int, optional
        :param sizeZ: sizeZ, defaults to 1
        :type sizeZ: int, optional
        :param sizeT: sizeT, defaults to 1
        :type sizeT: int, optional
        :return: Image
        :rtype: ImgPlus
        """        

        # check if scaleZ has a valid value to call modify the properties
        if scaleZ is None:
            scaleZ = 1

        # run the image properties tool
        IJ.run(imp, "Properties...", "channels=" + str(sizeC) +
               " slices=" + str(sizeZ)
               + " frames=" + str(sizeT)
               + " unit=" + unit
               + " pixel_width=" + str(scaleX)
               + " pixel_height=" + str(scaleY)
               + " voxel_depth=" + str(scaleZ))

        # create new Calibration object
        newCal = Calibration()

        # set the new paramters
        newCal.pixelWidth = scaleX
        newCal.pixelHeight = scaleY
        newCal.pixelDepth = scaleZ

        # set the correct unit fro the scaling
        newCal.setXUnit(unit)
        newCal.setYUnit(unit)
        newCal.setZUnit(unit)

        # apply the new calibration
        imp.setCalibration(newCal)

        return imp
Esempio n. 3
0
    def setscale(imp,
                 scaleX=1.0,
                 scaleY=1.0,
                 scaleZ=1.0,
                 unit="micron"):
        """Set new scaling for image.

        :param imp: image
        :type imp: ImgPlus
        :param scaleX: scaleX, defaults to 1.0
        :type scaleX: float, optional
        :param scaleY: scaleY, defaults to 1.0
        :type scaleY: float, optional
        :param scaleZ: scaleZ, defaults to 1.0
        :type scaleZ: float, optional
        :param unit: scaling unit, defaults to "micron"
        :type unit: str, optional
        :return: image
        :rtype: ImgPlus
        """  


        # check if scaleZ has a valid value to call modify the scaling
        if scaleZ is None:
            scaleZ = 1.0

        # create new Calibration object
        newCal = Calibration()

        # set the new paramters
        newCal.pixelWidth = scaleX
        newCal.pixelHeight = scaleY
        newCal.pixelDepth = scaleZ

        # set the correct unit fro the scaling
        newCal.setXUnit(unit)
        newCal.setYUnit(unit)
        newCal.setZUnit(unit)

        # apply the new calibratiion
        imp.setCalibration(newCal)

        return imp
Esempio n. 4
0
    def setproperties(imp,
                      scaleX=1.0,
                      scaleY=1.0,
                      scaleZ=1.0,
                      unit="micron",
                      sizeC=1,
                      sizeZ=1,
                      sizeT=1):

        # check if scaleZ has a valid value to call modify the properties
        if scaleZ is None:
            scaleZ = 1

        # run the image properties tool
        IJ.run(imp, "Properties...", "channels=" + str(sizeC)
               + " slices=" + str(sizeZ)
               + " frames=" + str(sizeT)
               + " unit=" + unit
               + " pixel_width=" + str(scaleX)
               + " pixel_height=" + str(scaleY)
               + " voxel_depth=" + str(scaleZ))

        # create new Calibration object
        newCal = Calibration()

        # set the new paramters
        newCal.pixelWidth = scaleX
        newCal.pixelHeight = scaleY
        newCal.pixelDepth = scaleZ

        # set the correct unit fro the scaling
        newCal.setXUnit(unit)
        newCal.setYUnit(unit)
        newCal.setZUnit(unit)

        # apply the new calibration
        imp.setCalibration(newCal)

        return imp