@@ -17,14 +17,14 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
1717 cells : any ;
1818 session : any ;
1919 clickedUnitId : number ;
20+ clickedUnitIndex : number ;
2021 cellsByProbeIns = [ ] ;
2122 sortedCellsByProbeIns = [ ] ;
2223 plot_data ;
2324 plot_layout ;
2425 plot_config ;
2526
2627 targetClusterRowInfo = [ ] ;
27- targetUnitId ;
2828 targetClusterDepth ;
2929 targetClusterAmp ;
3030 targetProbeIndex ;
@@ -59,6 +59,7 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
5959
6060 ngOnInit ( ) {
6161 this . session = this . sessionInfo ;
62+ this . clickedUnitIndex = 0 ;
6263 let probeCount = 0
6364 while ( probeCount < this . sessionInfo [ 'probe_count' ] ) {
6465 this . probeInsertions . push ( probeCount + 1 ) ;
@@ -72,7 +73,7 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
7273 . subscribe ( ( cellListData ) => {
7374 this . unitBehaviorLoading = false ;
7475 this . unitPsthLoading = false ;
75- console . log ( 'logging retrieved cell list data: ' , cellListData ) ;
76+ // console.log('logging retrieved cell list data: ', cellListData);
7677 if ( Object . entries ( cellListData ) . length > 0 ) {
7778 this . cells = cellListData ;
7879 const x_data = [ ] ;
@@ -117,7 +118,6 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
117118 this . color_data_adjusted = color_data . map ( function ( elem ) {
118119 return `rgba(0, 125, ${ 255 * ( elem - Math . min ( ...color_data ) ) / ( Math . max ( ...color_data ) - Math . min ( ...color_data ) ) } , 0.33)`
119120 } ) ;
120- this . targetUnitId = 1 ;
121121 this . clickedUnitId = 1 ;
122122 // console.log('adjusted color data:', this.color_data_adjusted);
123123 this . plot_data = [ {
@@ -180,9 +180,9 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
180180 ngDoCheck ( ) {
181181 const markerColors = [ ] ;
182182 if ( this . plot_data ) {
183- if ( this . plot_data [ 0 ] [ 'x' ] && this . clickedUnitId > - 1 ) {
183+ if ( this . plot_data [ 0 ] [ 'x' ] && this . clickedUnitIndex > - 1 ) {
184184 for ( let i = 0 ; i < this . plot_data [ 0 ] [ 'x' ] . length ; i ++ ) {
185- if ( this . clickedUnitId - 1 === i ) {
185+ if ( this . clickedUnitIndex === i ) {
186186 markerColors . push ( 'rgba(0, 0, 0, 1)' ) ; // black
187187 } else {
188188 markerColors . push ( this . color_data_adjusted [ i ] ) ;
@@ -199,9 +199,7 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
199199 // console.log('markerColors: ', markerColors);
200200 }
201201
202- if ( this . targetUnitId ) {
203- this . cells
204- }
202+
205203
206204 }
207205 ngOnDestroy ( ) {
@@ -267,7 +265,6 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
267265 } ] ;
268266 this . unitBehaviorLoading = false ;
269267 this . unitPsthLoading = false ;
270- this . targetUnitId = 1 ;
271268 this . clickedUnitId = 1 ;
272269 // console.log('plot data for probe (' + probeInsNum + ') is - ', this.plot_data);
273270 }
@@ -276,22 +273,22 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
276273 const element = this . el_nav . nativeElement . children [ 1 ] ;
277274 // console.log('cluster selected from cluster plot!');
278275 // console.log(element);
279- console . log ( 'data is: ' , data ) ;
276+ // console.log('data is: ', data);
280277 const rows = element . querySelectorAll ( 'tr' ) ;
281- console . log ( 'printing rows' ) ;
282- console . log ( rows ) ;
283- // this.targetUnitId = this.clickedUnitId;
278+ // console.log('printing rows');
279+ // console.log(rows);
284280 // console.log('clicked unitId is: ', this.clickedUnitId);
285281 if ( data [ 'points' ] && data [ 'points' ] [ 0 ] [ 'customdata' ] ) {
286- console . log ( 'data[points][0] is: ' , data [ 'points' ] [ 0 ] ) ;
282+ // console.log('data[points][0] is: ', data['points'][0]);
287283 this . clickedUnitId = data [ 'points' ] [ 0 ] [ 'customdata' ] ;
288- this . targetUnitId = this . clickedUnitId ;
289- console . log ( 'clicked unitId according to data is: ' , data [ 'points' ] [ 0 ] [ 'customdata' ] ) ;
290- for ( const row of rows ) {
284+ for ( const [ ind , row ] of Object . entries ( rows ) ) {
285+
286+
291287 // console.log('row inner text is - ', row['innerText']);
292288 if ( this . clickedUnitId == row [ 'innerText' ] . split ( ' ' ) [ 0 ] ) {
293- console . log ( 'row unit id is - ' , row [ 'innerText' ] . split ( ' ' ) [ 0 ] ) ;
289+ // console.log('row unit id is - ', row['innerText'].split(' ')[0]);
294290 const unitId = row [ 'innerText' ] . split ( ' ' ) [ 0 ] ;
291+ this . clickedUnitIndex = parseInt ( ind , 10 ) ;
295292 row . scrollIntoView ( {
296293 behavior : 'smooth' ,
297294 block : 'center'
@@ -308,49 +305,34 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
308305 }
309306
310307 clusterSelectedTable ( unit_id ) {
311- // console.log('table row selected!')
312- const element = this . el_nav . nativeElement . children [ 1 ] ;
313- const rows = element . querySelectorAll ( 'tr' ) ;
314- this . clickedUnitId = unit_id ;
315- this . targetUnitId = this . clickedUnitId ;
308+
309+ for ( const [ index , unit ] of Object . entries ( this . cellsByProbeIns ) ) {
310+ if ( unit [ 'unit' ] === unit_id ) {
311+
312+ this . clickedUnitIndex = parseInt ( index , 10 ) ;
313+ this . clickedUnitId = unit_id ;
314+ }
315+ }
316+ // const element = this.el_nav.nativeElement.children[1];
317+ // const rows = element.querySelectorAll('tr');
318+ // this.clickedUnitId = unit_id;
316319
317320 }
318321
319322 navigate_cell_plots ( event , direction ) {
320- // console.log('navigation activated')
321- // let element = this.el_nav.nativeElement.children[1];
322- // let rows = element.querySelectorAll('tr');
323- // let HLrowID = element.querySelectorAll('#highlighted-row');
324- // console.log('element: ', element)
325- // console.log('rows: ', rows)
326- // console.log('highlighted id: ', HLrowID)
327- // console.log('highlighted id[0]: ', HLrowID[0])
328- // console.log('highlighted id[0] type: ', typeof HLrowID[0])
329- // console.log('highlighted id[0][outerText]: ', HLrowID[0]['outerText'])
330- // console.log('=============================')
331- // rows.forEach((row, index) => {
332- // if (row.id == 'highlighted-row') {
333- // console.log('highlighted row at index - ', index)
334- // console.log('highlighted row at rowindex - ', row['rowIndex'])
335- // console.log('unit - ', row['outerText'].split('')[2])
336- // }
337- // })
338-
339- // console.log('clickedUnitId before - ', this.clickedUnitId);
340323 if ( direction === 'up' ) {
341- if ( this . clickedUnitId - 1 > - 1 ) {
342- this . clickedUnitId -= 1 ;
343- this . targetUnitId = this . clickedUnitId ;
324+ if ( this . clickedUnitIndex - 1 > - 1 ) {
325+ this . clickedUnitIndex -= 1 ;
326+
344327 }
345- // console.log('clickedUnitId after - ', this.clickedUnitId);
346328 }
347329 if ( direction === 'down' ) {
348- if ( this . clickedUnitId + 1 < this . plot_data [ 0 ] [ 'x' ] . length + 1 ) {
349- this . clickedUnitId += 1 ;
350- this . targetUnitId = this . clickedUnitId ;
330+ if ( this . clickedUnitIndex + 1 < this . plot_data [ 0 ] [ 'x' ] . length + 1 ) {
331+ this . clickedUnitIndex += 1 ;
351332 }
352- // console.log('clickedUnitId after - ', this.clickedUnitId);
353333 }
334+ // console.log('this.cellsByProbeIns[this.clickedUnitId][unit]: ', this.cellsByProbeIns[this.clickedUnitIndex]['unit'])
335+ this . clickedUnitId = this . cellsByProbeIns [ this . clickedUnitIndex ] [ 'unit' ] ;
354336 }
355337
356338 // sortData(sort: Sort) {
0 commit comments