Commit f0fd5bbe authored by Andrew Cohen's avatar Andrew Cohen

matlab recursive import

parent f6388ebf
......@@ -38,3 +38,4 @@ bin/*
/matlab/buildOutput/*
*.asv
dist/*
/matlab/buildOutput/*
......@@ -70,6 +70,16 @@
"args":["g:/leverjs/Temple/Embryonic", "--port=3101"],
"protocol": "auto"
},
{
"type": "node",
"request": "launch",
"name": "json2lever",
"cwd": "${workspaceRoot}\\leverjs",
"program": "${workspaceRoot}\\leverjs\\JSONtoLEVER.js",
"args":["C:\\z\\leverjs\\Dario\\PC3 siCTRL_Sep07\\01_63x2x_10intsec.json","--force"],
"protocol": "auto"
}
]
}
\ No newline at end of file
......@@ -59,7 +59,7 @@
<div id='sbImport' style='display:none'>
<table id="ImportTable"> </table>
<button class= sbButton id="importButton" tabindex="1" onclick="importFolder()" > Import to Folder </button>
<div><br><i class="fa fa-cog fa-spin fa-2x fa-fw" aria-hidden="true" id='busySpinner' style="display:none;"></i> </div>
<div><br><i class="fa fa-cog fa-spin fa-2x fa-fw" aria-hidden="true" id='importSpinner' style="display:none;"></i> </div>
<div id='importStatus'></div>
</div>
<div id='sbProcess' style='display:none'>
......
......@@ -74,20 +74,26 @@ function createColorTable(lDB,fnCallback)
} //createColorTable
function addLeverTable(lDB)
function addLeverTable(lDB,fnCallback)
{
// timestamp creation
var cmd='DROP TABLE IF EXISTS tblLever';
lDB.exec(cmd);
cmd = 'CREATE TABLE tblLever (version string,date string)';
lDB.exec(cmd);
lDB.exec(cmd,function(){
const fs = require('fs')
var packageInfo = JSON.parse(fs.readFileSync('../package.json', 'utf8'))
var version = packageInfo.version;
cmd='INSERT INTO tblLever (version,date) VALUES("'+version+'",datetime("now","localtime"))';
lDB.exec(cmd,function(){
if (undefined!==fnCallback) {
fnCallback();
}
});
});
// get package.json version
const fs = require('fs')
var packageInfo = JSON.parse(fs.readFileSync('../package.json', 'utf8'))
var version = packageInfo.version;
cmd='INSERT INTO tblLever (version,date) VALUES("'+version+'",datetime("now","localtime"))';
lDB.exec(cmd);
} // addLeverTable
// use a json file (from microscopedata.reader) to intialize a new sqlite db for leverjs
......@@ -201,13 +207,14 @@ function createNewDB(LEVERfileName,CONSTANTS,fnCompleteCallback)
'userID STRING,PRIMARY KEY(cellID_src,cellID_dst))';
addLeverTable(lDB);
lDB.parallelize();
lDB.close(function(err) {
if (null!=fnCompleteCallback)
fnCompleteCallback();
addLeverTable(lDB,function(){
lDB.parallelize();
lDB.close(function(err) {
if (null!=fnCompleteCallback)
fnCompleteCallback();
});
});
} // createNewDB
......
......@@ -32,11 +32,12 @@ function importFolder()
else
importPath = dbAlgorithms.getBinOrPrebuilt('run_importFolder.sh');
var childWD=path.join(process.cwd(),'matlab');
if (isWin)
global.matlabChild = spawn(importPath,[inputDir,leverDir]);
global.matlabChild = spawn(importPath,[inputDir,leverDir],{cwd:childWD});
else
global.matlabChild = spawn(importPath,['/usr/local/MATLAB/R2017a/',inputDir,leverDir]);
global.matlabChild = spawn(importPath,['/usr/local/MATLAB/R2017a/',inputDir,leverDir],{cwd:childWD});
var status=document.getElementById('importStatus');
......
......@@ -15,7 +15,7 @@ EMPTY_STRLEN=3;
% generate h5 and json
if length(rawFolder) > EMPTY_STRLEN
if exist(rawFolder,'dir')
MicroscopeData.Original.ConvertDir(rawFolder,leverFolder);
MicroscopeData.Original.ConvertDir('h5',rawFolder,leverFolder);
elseif exist(rawFolder,'file')
[imDir,imName,ext]=fileparts(rawFolder);
MicroscopeData.Original.ConvertData(imDir,[imName ext],leverFolder,'prompt',false);
......@@ -32,7 +32,7 @@ if length(leverFile) > EMPTY_STRLEN
leverFile=[datasetName '.LEVER'];
end
else
datasetName='*';
datasetName='**/*';
end
% generate lever
......@@ -40,9 +40,9 @@ end
jsonPath=fullfile(leverFolder,[datasetName '.json']);
flist=dir(jsonPath);
for ff=1:length(flist)
jsonName=fullfile(leverFolder,flist(ff).name);
jsonName=fullfile(flist(ff).folder,flist(ff).name);
[~,js,~]=fileparts(jsonName);
lname=fullfile(leverFolder,[js '.LEVER']);
lname=fullfile(flist(ff).folder,[js '.LEVER']);
if exist(lname,'file')
continue
end
......@@ -63,14 +63,14 @@ chunkSize = [ 128,128,128 ; 64,64,64];
leverPath=fullfile(leverFolder,[datasetName '.LEVER']);
flist=dir(leverPath);
for ff=1:length(flist)
leverName=fullfile(leverFolder,flist(ff).name);
leverName=fullfile(flist(ff).folder,flist(ff).name);
conn = database(leverName, '','', 'org.sqlite.JDBC', 'jdbc:sqlite:');
CONSTANTS=Read.getConstants(conn);
[~,ds,ext]=fileparts(leverName);
if CONSTANTS.imageData.Dimensions(3)>1
% 3d
% delete current images
mrFolder=fullfile(leverFolder,ds);
mrFolder=fullfile(flist(ff).folder,ds);
if exist(mrFolder,'dir') & bDeleteMRimages
rmdir(mrFolder, 's');
end
......@@ -85,7 +85,7 @@ for ff=1:length(flist)
continue
end
% now do the export
Import.generateMRvolumes(imData,chunkSize,leverFolder);
Import.generateMRvolumes(imData,chunkSize,flist(ff).folder);
else
% untested...
dsPath=fullfile(leverFolder,ds);
......
function importFolder(rawFolder,leverFolder)
fprintf(1,'importFolder: rawFolder=%d leverFolder=%s\n',rawFolder,leverFolder);
fprintf(1,'importFolder: rawFolder=%s leverFolder=%s\n',rawFolder,leverFolder);
Import.leverImport(rawFolder,leverFolder,[],1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment