Skip to content

Commit cb04bb6

Browse files
author
Dan Levitas
committed
[FIX] fix IntendedFor issue on DS, organize objs by AcqTim, tighten entity labels
1 parent e4fb1b9 commit cb04bb6

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

handler/ezBIDS_core/ezBIDS_core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -946,12 +946,6 @@ def generate_dataset_list(uploaded_files_list, exclude_data):
946946
'ConversionSoftware': 'ezBIDS',
947947
'ConversionSoftwareVersion': '1.0.0'
948948
}
949-
# if not os.path.exists(json_path):
950-
# with open(json_path, "w") as fp:
951-
# json.dump(json_data, fp, indent=3)
952-
# corresponding_files_list = corresponding_files_list + [json_path]
953-
# json_data = open(json_path)
954-
# json_data = json.load(json_data, strict=False)
955949

956950
# Find ImageModality
957951
if "Modality" in json_data:
@@ -1288,6 +1282,7 @@ def generate_dataset_list(uploaded_files_list, exclude_data):
12881282
dataset_list = sorted(dataset_list, key=itemgetter("AcquisitionDate",
12891283
"subject",
12901284
"session",
1285+
"AcquisitionTime",
12911286
"ModifiedSeriesNumber",
12921287
"json_path"))
12931288

@@ -2635,8 +2630,9 @@ def entity_labels_identification(dataset_list_unique_series, lookup_dic):
26352630

26362631
# If BIDS naming convention isn't detected, do a more thorough check for certain entities labels
26372632
# task
2638-
func_rest_keys = ["rest", "rsfmri", "fcmri"]
2639-
if any(x in re.sub("[^A-Za-z0-9]+", "", sd).lower() for x in func_rest_keys) and not series_entities["task"]:
2633+
func_rest_keys = ["rest", "rsfmri", "fcmri", "resting"]
2634+
# if any(x in re.sub("[^A-Za-z0-9]+", "", sd).lower() for x in func_rest_keys) and not series_entities["task"]:
2635+
if any(x in func_rest_keys for x in sd.split('_')) and not series_entities["task"]:
26402636
series_entities["task"] = "rest"
26412637
else:
26422638
match_index = [
@@ -2730,6 +2726,10 @@ def entity_labels_identification(dataset_list_unique_series, lookup_dic):
27302726
else:
27312727
pass
27322728

2729+
# rec (reconstruction)
2730+
if series_entities['reconstruction'] == 'pointspreadfunctionmodellingtimeofflight':
2731+
series_entities['reconstruction'] = 'PSTOF'
2732+
27332733
# Make sure any found entities are allowed for specific datatype/suffix pair
27342734
if unique_dic["type"] != "exclude":
27352735
datatype = unique_dic["datatype"]

ui/src/Objects.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,6 @@ export default defineComponent({
440440
return {
441441
so: null as IObject | null, //selected object
442442
sess: null as OrganizedSession | null, //selected session for IntendedFor handling
443-
showInfo: {} as any,
444-
petYaml: petYaml,
445-
aslYaml: aslYaml,
446-
fields: {},
447-
showDialog: false,
448-
rules: {},
449-
formData: {},
450443
};
451444
},
452445
@@ -679,10 +672,6 @@ export default defineComponent({
679672
'It is required that perfusion m0scan images have IntendedFor set to at least 1 series ID.'
680673
);
681674
}
682-
// let warningMessage = "It is recommended that these images have IntendedFor set to at least 1 object. This is necessary if you plan on using processing BIDS-apps such as fMRIPrep"
683-
// if (!o.validationWarnings.includes(warningMessage)) {
684-
// o.validationWarnings.push(warningMessage);
685-
// }
686675
}
687676
//Ensure other fmap series aren't included in the IntendedFor mapping
688677
if (o.IntendedFor.length > 0) {

ui/src/libUnsafe.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,12 @@ export function setIntendedFor($root: IEzbids) {
557557
// Loop through sections
558558
sectionIDs.forEach((s: number) => {
559559
let section = sesGroup.objects.filter(
560-
(e) => e.analysisResults.section_id === s && !e._exclude && e._type != 'exclude'
560+
(e) => e.analysisResults.section_id === s && !e._exclude && e._type !== 'exclude'
561561
);
562562

563563
section.forEach((obj: IObject) => {
564564
//add IntendedFor information
565565
if (obj._type.startsWith('fmap/') || obj._type === 'perf/m0scan') {
566-
Object.assign(obj, { IntendedFor: [] });
567566
let correspindingSeriesIntendedFor = $root.series[obj.series_idx].IntendedFor;
568567
if (correspindingSeriesIntendedFor !== undefined && correspindingSeriesIntendedFor !== null) {
569568
correspindingSeriesIntendedFor.forEach((i: number) => {
@@ -575,6 +574,22 @@ export function setIntendedFor($root: IEzbids) {
575574
}
576575
});
577576
}
577+
if (obj.hasOwnProperty('IntendedFor')) {
578+
if (obj.IntendedFor?.length !== 0) {
579+
obj.IntendedFor?.forEach((e) => {
580+
let IntendedForObj = section.filter((o) => o.idx === e);
581+
if (!IntendedForObj.length) {
582+
let badIndex = obj.IntendedFor?.indexOf(e);
583+
delete obj.IntendedFor[Object.keys(obj.IntendedFor)[badIndex]];
584+
if (Object.keys(obj.IntendedFor).length === 0) {
585+
obj.analysisResults.warnings = [
586+
'It is recommended that field map (fmap) images have IntendedFor set to at least 1 series ID. This is necessary if you plan on using processing BIDS-apps such as fMRIPrep',
587+
];
588+
}
589+
}
590+
});
591+
}
592+
}
578593
}
579594

580595
// check B0FieldIdentifier and B0FieldSource information
@@ -1821,7 +1836,6 @@ export function metadataAlerts(
18211836
sidecarMetadataValue.includes('none')
18221837
) {
18231838
// Required based on contain conditional between BIDS and sequence metadata
1824-
console.log('AAAAAAA', fieldName, sidecarMetadataValue);
18251839
requiredFields.push(fieldName);
18261840
}
18271841
}

ui/src/store/index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,17 @@ const store = createStore({
605605
const bses_idx = b.session_idx;
606606
if (ases_idx != bses_idx) return ases_idx - bses_idx;
607607

608-
const amodseriesnum = a.ModifiedSeriesNumber;
609-
const bmodseriesnum = b.ModifiedSeriesNumber;
610-
if (amodseriesnum && bmodseriesnum && amodseriesnum != bmodseriesnum)
611-
return amodseriesnum.localeCompare(bmodseriesnum);
608+
// Shouldn't use this anymore, use AcquisitionTime instead
609+
// const amodseriesnum = a.ModifiedSeriesNumber;
610+
// const bmodseriesnum = b.ModifiedSeriesNumber;
611+
// if (amodseriesnum && bmodseriesnum && amodseriesnum != bmodseriesnum)
612+
// return amodseriesnum.localeCompare(bmodseriesnum);
613+
614+
const aAcqTime = a.AcquisitionTime;
615+
const bAcqTime = b.AcquisitionTime;
616+
if (aAcqTime && bAcqTime) {
617+
return aAcqTime.localeCompare(bAcqTime);
618+
}
612619

613620
const apath = a.items[0].path;
614621
const bpath = b.items[0].path;

0 commit comments

Comments
 (0)