Skip to content

Commit 5947afa

Browse files
authored
Merge pull request #11 from MELDProject/dev_v1.0.1
release V1.0.1
2 parents f229d92 + 6c12e07 commit 5947afa

19 files changed

+261
-210
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Note:
1313
- You will need the following demographic information (age at scan & sex) to run AID-HS on your patient's T1 MRI scan.
1414
- AID-HS has been developed on T1w scans acquired at 3T. It has not yet been thoroughly evaluated on 1.5T and 7T data
1515

16+
**<span style="color: red;">SIGN UP TO THE AID-HS MAILING LIST</span>**:
17+
We request that all AID-HS users sign up to the mailing list. If you are using AID-HS, please send an email to `[email protected]` with the subject 'Request to be added to the AID-HS mailing list' and provide use with your name and institute. This will ensure that we can update you about bug fixs and new releases.
18+
19+
**<span style="color: red;">EXISTING USERS: PLEASE UPDATE TO VERSION V1.0.1</span>**:
20+
We have released AID-HS V1.0.1 which fixes a couple of issues found by users. For more information about the release please see [AID-HS V1.0.1](https://github.com/MELDProject/AID-HS/releases/tag/v1.0.1). To update your code please follow the guidelines [Updating AID-HS to V1.0.1](https://aid-hs.readthedocs.io/en/latest/FAQs.html#Updating-AID-HS-to-V1.0.1) from our FAQ.
21+
22+
1623
Pipeline overview:\
1724
<img src="https://raw.githubusercontent.com//MELDProject/AID-HS/main/docs/images/overview_pipeline.jpg " height="500" />
1825

@@ -30,6 +37,10 @@ You can install and use the AID-HS pipeline with :
3037

3138
**YouTube tutorial available for the [docker and singularity installation](https://www.youtube.com/watch?v=RRAET7r05ys&t=11s&ab_channel=MELDproject)**
3239

40+
**FAQs**
41+
If you have a question or if you are running into issues at any stage (installation/use/interpretation), have a look at our [FAQs](https://aid-hs.readthedocs.io/en/latest/FAQs.html) page as we may have already have a solution.
42+
43+
3344
### Running the pipeline
3445
Once installed you will be able to use the AID-HS pipeline on your data following the steps:
3546
1. Prepare your data : [guidelines](https://aid-hs.readthedocs.io/en/latest/prepare_data.html)

aidhs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = __maintainer__ = "Mathilde Ripart"
22
__email__ = "[email protected]"
3-
__version__ = "0.1.0"
3+
__version__ = "1.0.1"

aidhs/aidhs_cohort_hip.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def get_subject_ids(self, **kwargs):
329329
if isinstance(site_codes, str):
330330
site_codes = [site_codes]
331331
# get scanners
332-
scanners = kwargs.get("scanners", ["3T", "15T"])
332+
scanners = kwargs.get("scanners", ["3T", "15T", "XT"])
333333
if not isinstance(scanners, list):
334334
scanners = [scanners]
335335

@@ -447,16 +447,16 @@ def __init__(self, subject_id, cohort):
447447
#adapted for hippo
448448
@property
449449
def scanner(self):
450+
# Note: no need to specify scanner strength with AIDHS pipeline, but still need it to be compatible with previous AIDHS dataset
450451
scanner = self.get_demographic_features('Scanner')
452+
if scanner is None:
453+
scanner="XT" #no need to specify
451454
if scanner in ("15T" , "1.5T" , "15t" , "1.5t" ):
452-
scanner="15T"
455+
scanner="15T" # to be compatible with old way
453456
elif scanner in ("3T" , "3t" ):
454-
scanner="3T"
457+
scanner="3T" # to be compatible with old way
455458
else:
456-
print(
457-
f"Error: incorrect scanner for {self.subject_id}. Unable to determine if scanner 1.5T or 3T "
458-
)
459-
sys.exit()
459+
scanner="XT" #no need to specify
460460
return scanner
461461

462462
#adapted for hippo
@@ -480,6 +480,11 @@ def surf_dir_path(self, hemi):
480480
"""return path to features dir (surf_dir)"""
481481
return os.path.join(self.site_code, self.scanner, self.group, self.subject_id, hemi)
482482

483+
def find_path(self, name):
484+
""" Find the first object with the subject id in the hdf5"""
485+
if self.subject_id in name:
486+
return name
487+
483488
@property
484489
def is_patient(self):
485490
return self.group == "patient"
@@ -499,10 +504,10 @@ def get_lesion_hemisphere(self):
499504
return None
500505

501506
with self.cohort._site_hdf5(self.site_code, self.group) as f:
502-
surf_dir_lh = f.require_group(self.surf_dir_path("lh"))
507+
surf_dir_lh = f[os.path.join(self.site_code, f[self.site_code].visit(self.find_path), "lh")]
503508
if ".on_lh.lesion.mgh" in surf_dir_lh.keys():
504509
return "lh"
505-
surf_dir_rh = f.require_group(self.surf_dir_path("rh"))
510+
surf_dir_rh = f[os.path.join(self.site_code, f[self.site_code].visit(self.find_path), "rh")]
506511
if ".on_lh.lesion.mgh" in surf_dir_rh.keys():
507512
return "rh"
508513
return None
@@ -514,7 +519,8 @@ def has_features(self, features):
514519
def get_feature_list(self, hemi="lh"):
515520
"""Outputs a list of the features a participant has for each hemisphere"""
516521
with self.cohort._site_hdf5(self.site_code, self.group) as f:
517-
keys = list(f[self.surf_dir_path(hemi)].keys())
522+
surf_dir_path = os.path.join(self.site_code, f[self.site_code].visit(self.find_path), hemi)
523+
keys = list(f[surf_dir_path].keys())
518524
if ".on_lh.lesion.mgh" in keys:
519525
keys.remove(".on_lh.lesion.mgh")
520526
return keys
@@ -573,6 +579,8 @@ def get_demographic_features(
573579

574580
if "urfer" in desired_name:
575581
matched_name = 'Freesurfer_nul'
582+
elif "Scanner" in desired_name:
583+
return None
576584
else:
577585
self.log.warning(f"Unable to find column matching {desired_name}, please double check for typos")
578586
return None
@@ -616,7 +624,7 @@ def load_feature_values(self, feature, hemi="lh"):
616624
feature_values = np.zeros(NVERT, dtype=np.float32)
617625
# read data from hdf5
618626
with self.cohort._site_hdf5(self.site_code, self.group) as f:
619-
surf_dir = f[self.surf_dir_path(hemi)]
627+
surf_dir = f[os.path.join(self.site_code, f[self.site_code].visit(self.find_path), hemi)]
620628
if feature in surf_dir.keys():
621629
feature_values[:] = surf_dir[feature][:]
622630
else:

aidhs/data_preprocessing.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def load_covars(self, subject_ids=None, demographic_file=DEMOGRAPHIC_FEATURES_FI
216216
else:
217217
print(f'ERROR: There is an issue with the coded sex of subject {subject}')
218218
group.append(subj.is_patient)
219-
sites_scanners.append(subj.site_code + "_" + subj.scanner)
219+
sites_scanners.append(subj.site_code) # just site code now
220220

221221
covars["ages"] = ages
222222
covars["sex"] = sex
@@ -263,8 +263,8 @@ def compute_avg_feature(self, feature):
263263
vals_avg.append(np.hstack([vals_avg_lh, vals_avg_rh]))
264264
subject_include[k] = True
265265
else:
266-
print("exclude")
267266
subject_include[k] = False
267+
print(f"INFO: exclude subjects {np.array(self.subject_ids)[~subject_include]}")
268268
if vals_avg:
269269
vals_avg = np.array(vals_avg)
270270
self.save_cohort_features(feature.format('avg'), vals_avg, np.array(self.subject_ids)[np.array(subject_include)])
@@ -294,8 +294,8 @@ def extract_volumes_avg(self, feature):
294294
vals.append(np.hstack([vals_lh, vals_rh]))
295295
subject_include[k] = True
296296
else:
297-
print("exclude")
298297
subject_include[k] = False
298+
print(f"INFO: exclude subjects {np.array(self.subject_ids)[~subject_include]}")
299299
if vals:
300300
vals = np.array(vals)
301301
self.save_cohort_features(feature, vals, np.array(self.subject_ids)[np.array(subject_include)])
@@ -493,8 +493,8 @@ def combat_whole_cohort(self, feature_name, outliers_file=None, combat_params_fi
493493
precombat_features.append(combined_hemis)
494494
combat_subject_include[k] = True
495495
else:
496-
print("exclude")
497496
combat_subject_include[k] = False
497+
print(f"INFO: exclude subjects {np.array(self.subject_ids)[~combat_subject_include]}")
498498
if precombat_features:
499499
precombat_features = np.array(precombat_features)
500500
# load in covariates - age, sex, group, site and scanner unless provided
@@ -677,12 +677,13 @@ def combat_new_subject(self, feature_name, combat_params_file):
677677
rh = subj.load_feature_values(feature_name, hemi="rh")[mask]
678678
combined_hemis = np.hstack([lh, rh])
679679
precombat_features.append(combined_hemis)
680-
site_scanner.append(subj.site_code + "_" + subj.scanner)
680+
site_scanner.append(subj.site_code) # just site code now
681681
subjects_included.append(subject)
682682
#if matrix empty, pass
683683
if precombat_features:
684684
combat_estimates = self.read_norm_combat_parameters(feature_name, combat_params_file)
685685
combat_estimates = self.unshrink_combat_estimates(combat_estimates)
686+
combat_estimates["batches"] = [x.split('_')[0] for x in combat_estimates["batches"]] # remove scanner strenght from the batch code if exist
686687
precombat_features = np.array(precombat_features)
687688
site_scanner = np.array(site_scanner)
688689
dict_combat = neuroCombatFromTraining(dat=precombat_features.T, batch=site_scanner, estimates=combat_estimates)
@@ -818,8 +819,8 @@ def asymmetry_internorm_subject(self, feature, cohort_for_norm=None, params_norm
818819
vals_asym = self.compute_asym(intra_norm)
819820
vals_asym_array.append(vals_asym)
820821
else:
821-
print('exlude subject {}'.format(id_sub))
822-
included_subjects[k] = False
822+
included_subjects[k] = False
823+
print(f"INFO: exclude subjects {np.array(self.subject_ids)[~included_subjects]}")
823824
vals_asym_array=np.array(vals_asym_array)
824825
# remove exclude subjects
825826
included_subjects = np.array(self.subject_ids)[included_subjects]

docs/FAQ.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)