Commit a3d5ae13 authored by Andrew Cohen's avatar Andrew Cohen

main flags for --image, execFile instead of spawn, lineage - fix for trackFeatures

parent c646e985
......@@ -17,15 +17,14 @@
"cwd": "${workspaceRoot}/elever",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/electron/dist/electron.exe"
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args": [
],
"program": "${workspaceRoot}/elever/main.js",
"protocol": "legacy"
"--image"],
"program": "${workspaceRoot}/elever/main.js"
},
{
"name": "Render Process",
"name": "experiment Render Process",
"type": "chrome",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
......@@ -37,6 +36,22 @@
"--remote-debugging-port=9222"
],
"sourceMaps": false
},
{
"name": "image Render Process",
"type": "chrome",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/electron/dist/electron.exe"
},
"runtimeArgs": [
"${workspaceRoot}/elever/main.js",
"--remote-debugging-port=9222",
"--image"
],
"sourceMaps": false
}
]
}
\ No newline at end of file
......@@ -9,28 +9,29 @@ const url = require('url')
const {ipcMain} = require('electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
let mainWindow;
function createWindow () {
console.log(process.argv);
function createWindow ()
{
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})
mainWindow.maximize();
// mainWindow.loadURL(url.format({
// pathname: path.join(__dirname,'..','leverjs', 'ExperimentWindow.html'),
// protocol: 'file:',
// slashes: true
// }));
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, '..','leverjs', 'ImageWindow.html'),
protocol: 'file:',
slashes: true
}));
var argv = require('minimist')(process.argv.slice(0));
var target;
if (true===argv.image) {
target='ImageWindow.html';
}
else {
target='ExperimentWindow.html';
}
mainWindow.loadURL(url.format({
pathname: path.join(__dirname,'..','leverjs', target),
protocol: 'file:',
slashes: true
}));
// Open the DevTools.
// mainWindow.webContents.openDevTools()
......
......@@ -308,7 +308,7 @@ function cmdLoop()
function launchTracker()
{
const path=require('path');
const spawn = require('child_process').spawn;
const spawn = require('child_process').execFile;
const dbAlgorithms=require('./dbAlgorithms.js');
var tracker;
var trackerPath;
......@@ -349,7 +349,7 @@ function launchTracker()
function launchMatlab()
{
const path=require('path');
const spawn = require('child_process').spawn;
const spawn = require('child_process').execFile;
const dbAlgorithms=require('./dbAlgorithms.js');
var matlab;
var matlabPath;
......
......@@ -135,12 +135,15 @@ function getBinOrPrebuilt(file)
// if file exists in ./bin use that, otherwise use ./prebuilt/file
const fs=require('fs');
const path=require('path');
var fname=path.join('./bin',file);
var fname=path.join(__dirname,'..','bin',file);
if (fs.existsSync(fname)) {
return fname;
}
fname=path.join('./prebuilt',file);
fname=path.join(__dirname,'..','prebuilt',file);
return fname;
} // getBinOrPrebuilt
......
......@@ -17,7 +17,7 @@ function importFolder()
{
const path=require('path');
const spawn = require('child_process').spawn;
const spawn = require('child_process').execFile;
var matlab;
var matlabPath;
......
......@@ -398,91 +398,47 @@ function getCellFeatures(lDB,rowsTracks,fnCallback)
fnCallback(rowsTracks);
return;
}
var sqlCmd = "PRAGMA table_info('tblCells')";
lDB.all(sqlCmd,function(err,rows){
if (err) {
console.log('getCellFeatures: '+err);
fnCallback(rowsTracks);
return;
}
var bFound=false;
for (var n=0;n<rows.length;n++)
if ('cellFeatures'===rows[n].name) {
bFound=true;
break;
//
let nTracksProcessed=0;
for (let iTrack=0;iTrack<rowsTracks.length;iTrack++) {
sqlCmd='SELECT time,cellFeatures,trackID FROM tblCells WHERE trackID='+rowsTracks[iTrack].trackID+
' AND cellFeatures IS NOT NULL';
lDB.all(sqlCmd,function(err,rowFeatures){
nTracksProcessed++;
if (err) {
console.error('getCellFeatures: '+err);
return;
}
if (!bFound) {
fnCallback(rowsTracks);
}
else {
for (var iTrack=0;iTrack<rowsTracks.length;iTrack++) {
sqlCmd='SELECT time,cellFeatures,trackID FROM tblCells WHERE trackID='+rowsTracks[iTrack].trackID;
lDB.all(sqlCmd,function(err,rowFeatures){
if (err) {
console.error('getCellFeatures: '+err);
fnCallback(rowsTracks);
return;
}
// now we have rowsFeatures, with cellFeatures for each cell on track
else if (0==rowFeatures.length){
fnCallback(rowsTracks);
return;
}
else {
var f0=JSON.parse(rowFeatures[0].cellFeatures);
var trackFeatures={};
for (var property in f0) {
if (f0.hasOwnProperty(property)) {
trackFeatures[property]={};
trackFeatures[property].values=[];
for (var iFeature=0;iFeature<rowFeatures.length;iFeature++) {
var fx=JSON.parse(rowFeatures[iFeature].cellFeatures);
if (null===fx)
continue;
trackFeatures[property].values.push([rowFeatures[iFeature].time,fx[property]]);
}
// each feature is array of [time,feature value]. we sort in ascending time
// trackFeatures[property].values[i][0]
trackFeatures[property].values.sort(function(a,b){
return a[0]-b[0]
});
// async queries -- loop counter from above is in wrong context...sigh...search
var bFound=false;
for (var trackSearch=0;trackSearch<rowsTracks.length;trackSearch++) {
if (rowsTracks[trackSearch].trackID===rowFeatures[0].trackID) {
bFound=true;
break;
}
}
if (bFound)
rowsTracks[trackSearch].trackFeatures=trackFeatures;
else
console.error('lineage.js: could not find track to assign features!')
}
}
} // else
// see if all tracks have a cellFeatures?
var bComplete=true;
for (var i=0;i<rowsTracks.length;i++) {
if (undefined===rowsTracks[i].trackFeatures) {
bComplete=false;
break;
// now we have rowsFeatures, with cellFeatures for each cell on track
else if (rowFeatures.length>0){
var f0=JSON.parse(rowFeatures[0].cellFeatures);
var trackFeatures={};
for (var property in f0) {
if (f0.hasOwnProperty(property)) {
trackFeatures[property]={};
trackFeatures[property].values=[];
for (var iFeature=0;iFeature<rowFeatures.length;iFeature++) {
var fx=JSON.parse(rowFeatures[iFeature].cellFeatures);
if (null===fx)
continue;
trackFeatures[property].values.push([rowFeatures[iFeature].time,fx[property]]);
}
// each feature is array of [time,feature value]. we sort in ascending time
// trackFeatures[property].values[i][0]
trackFeatures[property].values.sort(function(a,b){
return a[0]-b[0]
});
rowsTracks[iTrack].trackFeatures=trackFeatures;
}
if (bComplete)
fnCallback(rowsTracks);
}); // select cell features
} // iTrack
}
});
}
} // else
if (nTracksProcessed>=rowsTracks.length)
fnCallback(rowsTracks);
}); // select cell features
} // iTrack
} // getCellFeatures
// get family tracks from database. called by electron app (fnCallback empty) and lever server (fnCallback->response).
......
......@@ -188,7 +188,7 @@ function removeAllFromQ()
function addFileToProcess(leverCommand,nSlot)
{
const path=require('path');
const spawn = require('child_process').spawn;
const spawn = require('child_process').execFile;
var isWin = /^win/.test(process.platform);
var leverFile=leverCommand.leverFile;
......
......@@ -2,7 +2,7 @@
"name": "leverjs",
"version": "1.0.0",
"description": "live cell & organelle image analysis",
"main": "server.js",
"main": "elever/main.js",
"scripts": {
"start": "node_modules/.bin/electron ./eLever/main.js",
"postinstall": "electron-builder install-app-deps",
......
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