@@ -246,6 +246,7 @@ function previewdata(key, idx, isinternal, hastime) {
246246 isinternal,
247247 intdata : window . intdata ,
248248 } ) ;
249+ console . log ( "key in previewdata" , key ) ;
249250 if ( ! hasthreejs ) {
250251 $ . when (
251252 $ . getScript ( "https://mcx.space/cloud/js/OrbitControls.js" ) ,
@@ -255,9 +256,11 @@ function previewdata(key, idx, isinternal, hastime) {
255256 ) . done ( function ( ) {
256257 hasthreejs = true ;
257258 dopreview ( key , idx , isinternal , hastime ) ;
259+ console . log ( "into the previewdata function if" ) ;
258260 } ) ;
259261 } else {
260262 dopreview ( key , idx , isinternal , hastime ) ;
263+ console . log ( "into the previewdata function else" ) ;
261264 }
262265}
263266
@@ -281,8 +284,21 @@ function dopreview(key, idx, isinternal, hastime) {
281284 return ;
282285 }
283286 } else {
287+ // dataroot = key;
288+ // console.log("into dopreview external data's dataroot", dataroot);
289+
284290 if ( window . extdata && window . extdata [ idx ] && window . extdata [ idx ] [ 2 ] ) {
285- dataroot = window . extdata [ idx ] [ 2 ] ;
291+ if ( typeof key === "object" ) {
292+ dataroot = key ;
293+ console . log ( "if key is object" , typeof key ) ;
294+ } else {
295+ dataroot = window . extdata [ idx ] [ 2 ] ;
296+ console . log ( "type of key" , typeof key ) ;
297+ }
298+
299+ // dataroot = key;
300+
301+ console . log ( "into dopreview external data's dataroot" , dataroot ) ;
286302 } else {
287303 console . error ( "❌ External data not ready for index" , idx ) ;
288304 return ;
@@ -302,7 +318,9 @@ function dopreview(key, idx, isinternal, hastime) {
302318 dataroot = window . extdata [ idx ] [ 2 ] ;
303319 }
304320 } else if ( dataroot instanceof nj . NdArray ) {
321+ console . log ( "dataroot before ndim" , dataroot ) ;
305322 ndim = dataroot . shape . length ;
323+ console . log ( "ndim" , ndim ) ;
306324 }
307325
308326 if ( ndim < 3 && ndim > 0 ) {
@@ -327,9 +345,16 @@ function dopreview(key, idx, isinternal, hastime) {
327345 '<h4>Data preview</h4><a href="javascript:void(0)" class="closebtn" onclick="$(\'#chartpanel\').hide()" title="Close">×</a><div id="plotchart"></div>'
328346 ) ;
329347 if ( dataroot instanceof nj . NdArray ) {
348+ console . log ( "dataroot" , dataroot ) ;
330349 if ( dataroot . shape [ 0 ] > dataroot . shape [ 1 ] )
331350 dataroot = dataroot . transpose ( ) ;
351+ console . log ( "is nj.NdArray:" , dataroot instanceof nj . NdArray ) ;
352+ console . log ( "dtype:" , dataroot . dtype ) ;
353+ console . log ( "shape:" , dataroot . shape ) ;
354+ console . log ( "size:" , dataroot . size ) ;
355+
332356 let plotdata = dataroot . tolist ( ) ;
357+ console . log ( "plotdata" , plotdata ) ;
333358 if ( hastime . length == 0 ) {
334359 if ( plotdata [ 0 ] instanceof Array )
335360 plotdata . unshift ( [ ...Array ( plotdata [ 0 ] . length ) . keys ( ) ] ) ;
@@ -357,12 +382,14 @@ function dopreview(key, idx, isinternal, hastime) {
357382 : hastime [ i ] ;
358383 }
359384 let u = new uPlot ( opts , plotdata , document . getElementById ( "plotchart" ) ) ;
385+ console . log ( "first u" , u ) ;
360386 } else {
361387 let u = new uPlot (
362388 opts ,
363389 [ [ ...Array ( dataroot . length ) . keys ( ) ] , dataroot ] ,
364390 document . getElementById ( "plotchart" )
365391 ) ;
392+ console . log ( "second u" , u ) ;
366393 }
367394 // add spinner
368395 // --- NEW LOGIC for 2D plot ---
@@ -1782,6 +1809,7 @@ function previewdataurl(url, idx) {
17821809 }
17831810
17841811 var plotdata = bjd ;
1812+ console . log ( "plotdata" , plotdata ) ;
17851813
17861814 if ( linkpath . length > 1 && ! linkpath [ 1 ] . match ( / ^ M e s h [ N S E V T ] / ) ) {
17871815 let objpath = linkpath [ 1 ] . split ( / (?< ! \\ ) \. / ) ;
@@ -1855,6 +1883,7 @@ function previewdataurl(url, idx) {
18551883 plotdata . hasOwnProperty ( "data" ) &&
18561884 plotdata . data . hasOwnProperty ( "dataTimeSeries" )
18571885 ) {
1886+ console . log ( "into the datatimeseries condition" ) ;
18581887 let serieslabel = true ;
18591888 if ( plotdata . data . hasOwnProperty ( "measurementList" ) ) {
18601889 serieslabel = Array ( plotdata . data . measurementList . length ) ;
@@ -1866,6 +1895,8 @@ function previewdataurl(url, idx) {
18661895 plotdata . data . measurementList [ i ] . detectorIndex ;
18671896 }
18681897 }
1898+ console . log ( "serieslabel in plotdata.hasownproperty" , serieslabel ) ;
1899+ console . log ( "plotdata 2nd" , plotdata ) ;
18691900 previewdata (
18701901 nj . concatenate (
18711902 plotdata . data . time . reshape ( plotdata . data . time . size , 1 ) ,
@@ -1886,6 +1917,40 @@ function previewdataurl(url, idx) {
18861917 console . log ( "window.extdata in preview" , window . extdata ) ; //
18871918 }
18881919 window . extdata [ idx ] [ 2 ] = plotdata ;
1920+ // window.extdata[idx][2] = bjd;
1921+ // urldata[url] = bjd; // Update cache
1922+
1923+ // // Case 1: 2D Time-Series Data (fNIRS)
1924+ // if (
1925+ // bjd.hasOwnProperty("data") &&
1926+ // bjd.data.hasOwnProperty("dataTimeSeries")
1927+ // ) {
1928+ // console.log("into the datatimeseries condition");
1929+ // let serieslabel = true;
1930+ // if (bjd.data.hasOwnProperty("measurementList")) {
1931+ // serieslabel = Array(bjd.data.measurementList.length);
1932+ // for (let i = 0; i < serieslabel.length; i++) {
1933+ // serieslabel[i] =
1934+ // "S" +
1935+ // bjd.data.measurementList[i].sourceIndex +
1936+ // "D" +
1937+ // bjd.data.measurementList[i].detectorIndex;
1938+ // }
1939+ // }
1940+
1941+ // // Prepare the specific numjs array needed for the 2D plot
1942+ // const plotData2D = nj.concatenate(
1943+ // bjd.data.time.reshape(bjd.data.time.size, 1),
1944+ // bjd.data.dataTimeSeries
1945+ // ).T;
1946+
1947+ // // Trigger the preview with the 2D data
1948+ // previewdata(plotData2D, idx, false, serieslabel);
1949+ // } else {
1950+ // // Case 2: All Other Data (NIfTI, Mesh, etc.)
1951+ // // Trigger the preview with the complete processed object.
1952+ // previewdata(bjd, idx, false);
1953+ // }
18891954
18901955 // ✅ Special case: time series preview
18911956 if ( plotdata ?. data ?. dataTimeSeries ) {
0 commit comments