Ejemplo n.º 1
0
def convertFiles(pathToData, outFile, complib='zlib', complevel=9):

    seriesName = pathToData.split(os.sep)[-2]

    fnl = os.listdir(pathToData)
    fnl2 = [pathToData + f for f in fnl]

    f1 = read_kdf.ReadKdfData(fnl2[0])

    xSize, ySize = f1.shape[0:2]

    outF = tables.open_file(outFile, 'w')

    filt = tables.Filters(complevel, complib, shuffle=True)

    imageData = outF.create_earray(outF.root,
                                   'ImageData',
                                   tables.UInt16Atom(), (0, xSize, ySize),
                                   filters=filt,
                                   expectedrows=len(fnl2))

    for fn in fnl2:
        imageData.append(read_kdf.ReadKdfData(fn).reshape(1, xSize, ySize))

    outF.flush()
    outF.close()
Ejemplo n.º 2
0
def convertFile(pathToData,
                outFile,
                pixelsize=None,
                complib='zlib',
                complevel=9):

    #seriesName = pathToData.split(os.sep)[-2]

    #fnl = os.listdir(pathToData)
    #fnl2 = [pathToData + f for f in fnl]

    f1 = read_kdf.ReadKdfData(pathToData).squeeze()

    xSize, ySize = f1.shape[0:2]

    outF = tables.openFile(outFile, 'w')

    filt = tables.Filters(complevel, complib, shuffle=True)

    imageData = outF.createEArray(outF.root,
                                  'ImageData',
                                  tables.UInt16Atom(), (0, xSize, ySize),
                                  filters=filt,
                                  expectedrows=f1.shape[2])

    for i in range(f1.shape[2]):
        imageData.append(f1[:, :, i].reshape(1, xSize, ySize))

    hdh = MetaData.HDFMDHandler(outF, MetaData.PCODefault)

    if not pixelsize == None:
        hdh.setEntry('voxelsize.x', pixelsize)
        hdh.setEntry('voxelsize.y', pixelsize)

    outEvents = outF.createTable(outF.root,
                                 'Events',
                                 SpoolEvent,
                                 filters=tables.Filters(complevel=5,
                                                        shuffle=True))

    outF.flush()
    outF.close()
Ejemplo n.º 3
0
    def OnInit(self):
        #wx.InitAllImageHandlers()
        print((sys.argv))
        bg = None
        if (len(sys.argv) > 1):
            fnms = os.listdir(sys.argv[1])
        else:
            raise RuntimeError('Must provide list of files on command line')

        if (len(sys.argv) == 3):
            bg = read_kdf.ReadKdfData(sys.argv[2])[:, :, :, 0]

        fnames = []
        for fn in fnms:
            fnames.append(sys.argv[1] + fn)
        vframe = DSViewFrame(None, filenames=fnames, bg=bg)

        self.SetTopWindow(vframe)
        vframe.Show(1)
        return 1
Ejemplo n.º 4
0
    (options, args) = parser.parse_args()

    if options.data is None:
        print('Must give a file containing the data')
        sys.exit(1)
    if options.psf is None:
        print('Must give a file containing the psf')
        sys.exit(1)
    if options.out is None:
        print('Must give an output file')
        sys.exit(1)
    if options.kz is None:
        print('Must give the wavelength parameter')
        sys.exit(1)

    data = squeeze(read_kdf.ReadKdfData(options.data))
    psf = squeeze(read_kdf.ReadKdfData(options.psf))

    if not options.alpha is None:
        alpha = squeeze(read_kdf.ReadKdfData(options.alpha))
    else:
        alpha = zeros(shape(data), 'f')

    print((shape(data)))
    print((shape(alpha)))
    print((shape(psf)))

    servers = []
    if not options.servers is None:
        svrs = options.servers.split(',')
        for s in svrs:
Ejemplo n.º 5
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##################

from PIL import Image
import read_kdf
import sys

if not (len(sys.argv) == 3):
    raise RuntimeError('Usage: kdfToImage infile outfile')

inFile = sys.argv[1]
outFile = sys.argv[2]

im = read_kdf.ReadKdfData(inFile).squeeze()

mode = ''

if (im.dtype.__str__() == 'uint16'):
    mode = 'I;16'
elif (im.dtype.__str__() == 'float32'):
    mode = 'F'
else:
    raise RuntimeError('Error data type <%s> not supported') % im.dtype

Image.fromarray(im, mode).save(outFile)