From 1d65ce003823143d33beba03cc82729a6c975ce7 Mon Sep 17 00:00:00 2001 From: cjd24 Date: Thu, 19 Apr 2018 05:01:01 +0100 Subject: Added a write of the base teir JSON object, made the images actually write to file lol - still havent been able to tell if this is a working commit yet, need to try from the second teir onwards. --- src/conversion/czi/convertJxrs.py | 44 ++++++++++++++++++++------------------- src/conversion/czi/czi.ts | 18 +++++++++++----- 2 files changed, 36 insertions(+), 26 deletions(-) (limited to 'src/conversion') diff --git a/src/conversion/czi/convertJxrs.py b/src/conversion/czi/convertJxrs.py index 2ba81b3..f4b897f 100644 --- a/src/conversion/czi/convertJxrs.py +++ b/src/conversion/czi/convertJxrs.py @@ -8,19 +8,21 @@ coutner = 0 def convertjxrs(filename): - global counter - global totalFiles + global counter + global totalFiles try: asTif = filename.rsplit('.',1)[0] + ".tif" - check_call(['JxrDecApp', "-i", filename, "-o", asTif]) - check_call(['convert', asTif, filename.rsplit('.',1)[0] + ".png"]) - check_call(['rm', filename, asTif]) - counter += 1 - except: - print ("Processing Failed. Probably couldn't find decoder due to invalid system environment path, check this before debugging.") + check_call(['JxrDecApp', "-i", filename, "-o", asTif]) + check_call(['convert', asTif, filename.rsplit('.',1)[0] + ".png"]) + check_call(['rm', filename, asTif]) + counter += 1 + except Exception as help: + print ("Processing Failed. Probably couldn't find decoder due to invalid system environment path, check this before debugging."); + print ("Actual error was:"); + print (help); exit(0); - print (f"> Processed File: {counter}/{totalFiles} : {filename} --> {filename.rsplit('.',1)[0]}.png") + print (f"> Processed File: {counter}/{totalFiles} : {filename} --> {filename.rsplit('.',1)[0]}.png") if __name__ == "__main__": @@ -29,15 +31,15 @@ if __name__ == "__main__": print("\nMissing Argument!\n\nUsage:\npython3 convertJxrs.py ") exit(0) else: - print("=========== BEGIN JXR CONVERSION ===========") - print ('Files Dir: ' + argv[1] + '\n') - - filenames = glob(argv[1] + 'data-*.jxr') - counter = 0 - totalFiles = len(filenames) - - pool = ThreadPoolExecutor(5) - for f in pool.map(convertjxrs, filenames): - pass - pool.shutdown(True) - print("=========== FINISH JXR CONVERSION ===========") + print("=========== BEGIN JXR CONVERSION ===========") + print ('Files Dir: ' + argv[1] + '\n') + + filenames = glob(argv[1] + 'data-*.jxr') + counter = 0 + totalFiles = len(filenames) + + pool = ThreadPoolExecutor(5) + for f in pool.map(convertjxrs, filenames): + pass + pool.shutdown(True) + print("=========== FINISH JXR CONVERSION ===========") diff --git a/src/conversion/czi/czi.ts b/src/conversion/czi/czi.ts index 88a6814..c10a6f7 100644 --- a/src/conversion/czi/czi.ts +++ b/src/conversion/czi/czi.ts @@ -13,6 +13,7 @@ import { uuid } from '../../uuid' // Various constants for placing files and defining tiles const baseDirname: string = '/cs/scratch/cjd24/0701-extraction'; +const extensionBinariesDir: string = __dirname + `/../../../ext/bin/`; const extractionDirectory: string = `${baseDirname}/`; const outputImageData: string = `${baseDirname}-processed/`; const outputImageDirectory: string = `${baseDirname}-processed/data/`; @@ -530,8 +531,8 @@ const zoomTier: ( quadrents += `${outputImageDirectory}${previousHeightMap.plane[ys + 1][xs + 1].file} `; } - let outputFileName: string =`${outputImageData}tmp/${uuid.generate()}.png` - shell.exec(`vips arrayjoin "${quadrents}" ${outputFileName} --across ${across}`) + let outputFileName: string =`${outputImageData}tmp/${uuid.generate()}.png`; + shell.exec(`${extensionBinariesDir}vips arrayjoin "${quadrents}" ${outputFileName} --across ${across}`); // Rescale and push to file await sharp(outputFileName) @@ -614,12 +615,14 @@ const extrapolateDimension: ( y_offset: ys, width: tileSize, height: tileSize, - file: `img-${filecounter++}.png` + file: `img-${filecounter}.png` }); const sortedSegments: Segment[][] = orderSegments(findRelatedTiles(filteredDataBlocks, desired)); - await extractAndStitchChunks(sortedSegments, desired); + (await extractAndStitchChunks(sortedSegments, desired)) + .toFile(`${outputImageDirectory}img-${filecounter++}`); + process.stdout.write(">"); finalCZIJson.total_files++; } @@ -647,6 +650,7 @@ const extrapolateDimension: ( }; Begin computing zoom tiers...\n`); const retHeightMap: CZIHeightMap[] = [baseCZIHeightMap]; + writeJSONToFile(`${outputImageData}stageMap-${cVal}-${0}`, retHeightMap); for (let stage: number = 1; stage < Math.log2(maxZoom); stage++) { console.log(`Stage (${cVal * Math.log2(maxZoom) + 1 + stage}/${totalCs}):`); await zoomTier(retHeightMap[stage - 1]) @@ -704,7 +708,11 @@ const createSupportedViewsObject: () => void = (): void => { // Cleanup and create "smart" supported views object without whole metadata cleanSupportedViews(supportedViews); - supportedViews.scalable_image.metadata = {}; + supportedViews.scalable_image.metadata = { + tile_size: tileSize, + max_zoom: maxZoom, + tile_overlap: tileOverlap + }; writeJSONToFile( `${outputImageData}supported_views_minus_xml.json`, supportedViews); }; -- cgit v1.2.1