Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix general regression issues and implement other requested changes #105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/iblapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ def handle_q(subpath, args, proj, fetch_args=None, **kwargs):
training_status='training_status', good_enough_for_brainwide_map='good_enough_for_brainwide_map',
keep_all_rows=True
)
subj = subject.Subject().aggr(
subject.Death().proj('death_date') * dj.U('death_date'),
death_date='IFNULL(death_date, NULL)',
keep_all_rows=True)
regions = kwargs.get('brain_regions', None)
# expected format of brain_regions = ["AB", "ABCa", "CS of TCV"]
if regions is not None and len(regions) > 0:
Expand All @@ -268,7 +272,7 @@ def handle_q(subpath, args, proj, fetch_args=None, **kwargs):
# subject.SubjectLab() * subject.SubjectUser() *
# analyses_behavior.SessionTrainingStatus()) & args & brain_restriction)

q = ((acquisition.Session() * sess_proj * psych_curve * ephys_data * subject.Subject() *
q = ((acquisition.Session() * sess_proj * psych_curve * ephys_data * subj *
subject.SubjectLab() * subject.SubjectUser() * trainingStatus) & args & brain_restriction)
q = q.proj(*proj) if proj else q
dj.conn().query("SET SESSION max_join_size={}".format('18446744073709551615'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,60 @@ <h5>Mouse <{{ mouse?.subject_nickname }}> Info</h5>
</div>
<div class="row mouse-info-table">
<table class="table col-lg-4 col-sm-6 col-xs-12 table-striped table-bordered table-sm">
<tr>
<th>Mouse Nickname</th>
<td>{{ mouse?.subject_nickname }}</td>
</tr>
<tr>
<th>Mouse UUID</th>
<td>{{ mouse?.subject_uuid }}</td>
</tr>
<tr>
<th>Mouse DOB</th>
<td>{{ mouse?.subject_birth_date }}</td>
</tr>
<tr>
<th>Lab</th>
<td>{{ mouse?.lab_name }}</td>
</tr>
<tr>
<th>Sex</th>
<td>{{ mouse?.sex }}</td>
</tr>
<tr>
<th>Project</th>
<td>{{ mouse?.projects }}</td>
</tr>
<tr>
<th>User</th>
<td>{{ mouse?.responsible_user }}</td>
</tr>
<tbody>
<tr>
<th>Mouse Nickname</th>
<td>{{ mouse?.subject_nickname }}</td>
</tr>
<tr>
<th>Mouse UUID</th>
<td>{{ mouse?.subject_uuid }}</td>
</tr>
<tr>
<th>Mouse DOB</th>
<td>{{ mouse?.subject_birth_date }}</td>
</tr>
<tr>
<th>Lab</th>
<td>{{ mouse?.lab_name }}</td>
</tr>
<tr>
<th>Sex</th>
<td>{{ mouse?.sex }}</td>
</tr>
<tr>
<th>Project</th>
<td>{{ mouse?.projects }}</td>
</tr>
<tr>
<th>User</th>
<td>{{ mouse?.responsible_user }}</td>
</tr>
</tbody>
</table>
<table class="table col-lg-3 col-sm-6 col-xs-12 table-striped table-bordered table-sm">
<tr>
<th>Ear Mark</th>
<td>{{ mouse?.ear_mark }}</td>
</tr>
<tr>
<th>Mouse Line</th>
<td>{{ mouse?.subject_line }}</td>
</tr>
<tr>
<th>Source</th>
<td>{{ mouse?.subject_source }}</td>
</tr>
<tr>
<th>Protocol Number</th>
<td>{{ mouse?.protocol_number }}</td>
</tr>
<tr>
<th>Description</th>
<td>{{ mouse?.subject_description }}</td>
</tr>
<tbody>
<tr>
<th>Ear Mark</th>
<td>{{ mouse?.ear_mark }}</td>
</tr>
<tr>
<th>Mouse Line</th>
<td>{{ mouse?.subject_line }}</td>
</tr>
<tr>
<th>Source</th>
<td>{{ mouse?.subject_source }}</td>
</tr>
<tr>
<th>Protocol Number</th>
<td>{{ mouse?.protocol_number }}</td>
</tr>
<tr>
<th>Description</th>
<td>{{ mouse?.subject_description }}</td>
</tr>
</tbody>
</table>
<div class="spinning-brain-container col-xs-12 col-sm-6 col-lg-4" *ngIf="mouse">
<app-spinning-brain [mouseInfo]="mouse"></app-spinning-brain>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ label {
position: relative;
overflow-x: auto;
}

.flipped, .flipped .col-12
{
transform:rotateX(180deg);
-ms-transform:rotateX(180deg); /* IE 9 */
-webkit-transform:rotateX(180deg); /* Safari and Chrome */
}

td.mat-cell,
td.mat-footer-cell,
th.mat-header-cell {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,23 @@ <h4>
</mat-autocomplete>
</mat-form-field>

<div class="date-range-toggler">
<label for="isAlive">Mouse Vital Status</label>
<div>
Deceased&nbsp;<mat-slide-toggle name="isAlive" [checked]="isAlive" (change)="isAlive=!isAlive">Alive
</mat-slide-toggle>
</div>
</div>

<!-- // Brain Tree Selection Area -->
<div class="brain-tree-zone">
<mat-form-field>
<label>Brain Regions</label>
<input matInput (input)="filterChanged($event.target.value.toLowerCase())">
<input matInput type="text" name="brain_regions" formControlName="brain_regions">
<mat-autocomplete #autoCompRU="matAutocomplete">
<mat-option *ngFor="let responsible_user of dropDownMenuOptions.filteredResponsibleUserOptions | async"[value]="brain_regions"
(click)="updateMenu()">{{ brain_regions }}</mat-option>
</mat-autocomplete>
</mat-form-field>
<!-- <div>Selected Brain Region:
<div class="chip-list">
Expand Down Expand Up @@ -219,7 +231,7 @@ <h4>
<button mat-raised-button class="btn btn-refresh" (click)="refreshData()">Refresh Data</button>
</div>
</div>
<!-- <div class="checkbox-filters">
<div class="checkbox-filters">
<div class="chbox-filter">
<mat-checkbox class="nplot_status_chbox" [checked]="hideMissingPlots" (change)="toggleNplotStatus()">
Only show sessions with behavior plots
Expand All @@ -235,15 +247,15 @@ <h4>
Only show sessions with ephys data
</mat-checkbox>
</div>
</div> -->
</div>
</div>
</form>

<div [class]="isLoading && initialLoad ? 'loading-icon loading initial': isLoading ? 'loading-icon loading': 'loading-icon'">
<img src="assets/images/loading_icon.gif">
<p [class]="initialLoad ? 'session-list-loading-message show' : 'session-list-loading-message'"></p>
</div>
<div class="table-container">
<div class="table-container flipped">
<div class="session-list-loading-shade"
*ngIf="isLoadingTable">
<mat-spinner *ngIf="isLoadingTable"></mat-spinner>
Expand Down Expand Up @@ -304,6 +316,11 @@ <h4>
<td mat-cell *matCellDef="let session"class="to-center"> {{session.sex}} </td>
</ng-container>

<ng-container matColumnDef="death_date">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Mouse Vital Status </th>
<td mat-cell *matCellDef="let session"class="to-center"> {{session.death_date}} </td>
</ng-container>

<ng-container matColumnDef="nplot">
<th mat-header-cell *matHeaderCellDef> Plot Availability </th>
<td mat-cell *matCellDef="let session" class="to-center"> {{session.nplot.toString() | i18nSelect: nplotMap}} </td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export class SessionListComponent implements OnInit, OnDestroy {
sex: new FormArray([new FormControl(), new FormControl(), new FormControl()]),
subject_birth_date: new FormControl(),
subject_line: new FormControl(),
responsible_user: new FormControl()
responsible_user: new FormControl(),
brain_regions: new FormControl(),
death_date: new FormControl()
});
isLoading;
isLoadingTable = true;
Expand All @@ -65,6 +67,7 @@ export class SessionListComponent implements OnInit, OnDestroy {
sessionMinDate: Date;
sessionMaxDate: Date;
isSessionDateUsingRange: boolean;
isAlive: boolean
dropDownMenuOptions: any = {};
// filteredTaskProtocolOptions: Observable<string[]>;
// filteredSessionUuidOptions: Observable<string[]>;
Expand All @@ -83,7 +86,7 @@ export class SessionListComponent implements OnInit, OnDestroy {
// setup for the table columns
displayedColumns: string[] = ['session_lab', 'subject_nickname', 'subject_birth_date', 'session_start_time',
'task_protocol', 'subject_line', 'responsible_user',
'session_uuid', 'sex', 'subject_uuid', 'nplot', 'nprobe', 'session_project', 'good4bmap'];
'session_uuid', 'sex', 'death_date', 'subject_uuid', 'nplot', 'nprobe', 'session_project', 'good4bmap'];
nplotMap: any = { '0': '', '1': '\u2714' };
// setup for the paginator
dataSource;
Expand Down Expand Up @@ -338,52 +341,82 @@ export class SessionListComponent implements OnInit, OnDestroy {
.pipe(
startWith({}),
switchMap(() => {
let dj_restriction_conditions = [];

this.isLoadingTable = true;
if(this.sort.direction == ''){
this.sort.active = 'session_start_time';
this.sort.active = 'nprobe';
this.sort.direction = 'desc'
}
let filter = Object.assign({}, this.session_filter_form.getRawValue());
let newFilter = JSON.stringify(filter)

if(this.hideMissingPlots){
filter["nplot"] = 1;
}

if(this.hideNG4BrainMap){
filter["good_enough_for_brainwide_map"] = 1;
}

if(this.hideNotReady4Delay){
filter["training_status"] = "ready4delay";
}

if(this.hideMissingEphys){
dj_restriction_conditions.push("nprobe>0");
}

for (const [key, value] of Object.entries(filter)) {
if(key == 'sex'){
if(value[0] == true){
newObject[key] = 'F'
newObject[key] = 'F';
//female
continue
continue;
}
else if (value[1] == true){
newObject[key] = 'M'
newObject[key] = 'M';
//male
continue
continue;
}
else if (value[2] == true){
newObject[key] = 'U'
newObject[key] = 'U';
//undefined
continue
continue;
}
else{
continue
continue;
}
}
if(key == 'session_range_filter'){
for( const [key2, val] of Object.entries(value)){
if(val !== null){
newObject[key2] = val
newObject[key2] = val;
}
continue
continue;
}
}
if(key == 'brain_regions' && value !== null && value !== ""){
newObject["__json_kwargs"] = `{"brain_regions": ["${value}"]}`;
continue;
}
if(this.isAlive){
dj_restriction_conditions.push("death_date is null");
continue;
}
if(!this.isAlive){
dj_restriction_conditions.push("death_date is not null");
continue;
}
if(value !== null){
newObject[key] = value
newObject[key] = value;
}
}
this.isLoadingResults = true;

newObject["__page"] = this.paginator.pageIndex + 1;
newObject["__limit"] = this.paginator.pageSize;
newObject["__order"] = this.sort.active + ' ' + this.sort.direction
newObject["__order"] = this.sort.active + ' ' + this.sort.direction;
newObject["__json"] = JSON.stringify(dj_restriction_conditions);
return this.sessionService!.getSessions(
newObject)
.pipe(catchError(() => observableOf(null)));
Expand Down Expand Up @@ -474,7 +507,7 @@ export class SessionListComponent implements OnInit, OnDestroy {
private createMenu(restrictedSessions: Array<any>) {
const keys = ['task_protocol', 'session_start_time',
'session_uuid', 'session_lab', 'subject_birth_date', 'subject_line',
'subject_uuid', 'sex', 'subject_nickname', 'responsible_user', 'session_project'];
'subject_uuid', 'sex', 'subject_nickname', 'responsible_user', 'session_project', 'brain_regions', 'death_date'];

keys.forEach(key => {
this.uniqueValuesForEachAttribute[key] = new Set();
Expand Down Expand Up @@ -545,6 +578,8 @@ export class SessionListComponent implements OnInit, OnDestroy {
this.setDropDownFormOptions('filteredTaskProtocolOptions', this.session_filter_form.controls.task_protocol, 'task_protocol');
this.setDropDownFormOptions('filteredSubjectLineOptions', this.session_filter_form.controls.subject_line, 'subject_line');
this.setDropDownFormOptions('filteredResponsibleUserOptions', this.session_filter_form.controls.responsible_user, 'responsible_user');
this.setDropDownFormOptions('filteredBrainRegionsOptions', this.session_filter_form.controls.brain_regions, 'brain_regions');
this.setDropDownFormOptions('filteredDeathDateOptions', this.session_filter_form.controls.death_date, 'death_date');
}

/**
Expand Down Expand Up @@ -574,7 +609,7 @@ export class SessionListComponent implements OnInit, OnDestroy {
// The unique value does include the user restrction string, thus we need to add it to the validUniqueValues array
validUniqueValues.push(uniqueValue);
}

if (validUniqueValues.length > MAX_NUMBER_OF_SUGGESTIONS) {
return;
}
Expand Down Expand Up @@ -1157,27 +1192,31 @@ export class SessionListComponent implements OnInit, OnDestroy {
}
toggleNplotStatus() {
// hide or show sessions that have missing session plots
this.hideMissingPlots = !this.hideMissingPlots;
this.updateSelection();
this.isLoading = false;
this.paginator.pageIndex = 0;
this.ngAfterViewInit();
}
toggleNprobeStatus() {
// hide or show sessions that have missing ephys data (based on existence of probe insertion)
this.hideMissingEphys = !this.hideMissingEphys;
this.updateSelection();
this.isLoading = false;
this.paginator.pageIndex = 0;
this.ngAfterViewInit();
}

toggleG4BMviewStatus() {
// hide or show sessions that are not good enough for brain map
this.hideNG4BrainMap = !this.hideNG4BrainMap;
this.updateSelection();
this.isLoading = false;
this.paginator.pageIndex = 0;
this.ngAfterViewInit();
}

toggleR4DviewStatus() {
// hide or show session that are not ready for delay
this.hideNotReady4Delay = !this.hideNotReady4Delay;
this.updateSelection();
this.isLoading = false;
this.paginator.pageIndex = 0;
this.ngAfterViewInit();
}

//==**==**==**==**+=**+== [START] brain tree functions **==**==**==**==**==**==**==**==**==**+=//
Expand Down
Loading