ADNI to BIDS Keyerror

86 views
Skip to first unread message

Aya Rabea

unread,
Nov 18, 2024, 10:57:15 AM11/18/24
to Clinica

I encountered an error while attempting to convert ADNI data to BIDS format using T1-weighted images. 

WhatsApp Image 2024-11-18 at 5.50.14 PM.jpegUnfortunately, I am unable to resolve the issue on my own. Could you kindly assist me in identifying and correcting the problem?

For reference, I’ve attached a screenshot of the error message I received. If you need any additional information to help troubleshoot, please feel free to let me know.

Alice Joubert

unread,
Nov 19, 2024, 9:28:07 AM11/19/24
to Clinica
Hello Aya,

I will try to reproduce. Can you tell me : the version of clinica you're using, which clinical data you're using (all the files from our folder or only some ?), what command line you're using (any options ?) and if you know if this is subject specific ?

Best,

Alice

Matt Tharp

unread,
Jan 15, 2025, 9:13:28 AMJan 15
to Clinica
Hello all,

I've also encountered this error. For me, it is resolved by commenting out these lines

# -- Creation of sessions.tsv --
cprint("Creating sessions files...", lvl="info")
create_adni_sessions_dict(
bids_ids,
clinical_specifications_folder,
clinical_data_dir,
bids_subjects_paths,
)

As to specifically why some of us get this error with sessions.tsv, I'm unsure and haven't looked closely yet. Hope this helps.

Matt

Alice Joubert

unread,
Jan 16, 2025, 7:33:19 AMJan 16
to clinic...@googlegroups.com
Hello Matt !

Thanks for sharing your experience with this. Commenting is temporary and if you are not interested in having the metadata sessions.tsv files, but technically it works. Ideally we would like to fix it for good so if you have an idea as to when it happens (command line used, specific option, specific modality in your dataset), we are interested in having the information in order to reproduce the error !

Best,

Alice



--
You received this message because you are subscribed to the Google Groups "Clinica" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clinica-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/clinica-user/4ea212b2-4ed3-4778-8166-239f6f647b9cn%40googlegroups.com.

Matt Tharp

unread,
Jan 16, 2025, 9:22:14 AMJan 16
to Clinica
Hello Alice,

I took a closer look just now. On my end, this is happening because my ADNIMERGE.csv does not have an 'adas_q1' column. Upon downloading the latest ADNIMERGE from LONI, I also am not seeing 'adas_q1' there.

There variables are referenced in _write_adni_sessions_tsv as seen below:

def _write_adni_sessions_tsv(
df_subj_sessions: pd.DataFrame, bids_subjs_paths: list[Path]
):
"""Write the result of method create_session_dict into several TSV files.

Args:
df_subj_sessions: global dataframe containing clinical sessions data for all subjects
bids_subjs_paths: a list with the path to all bids subjects
"""

df_subj_sessions["adas_memory"] = (
df_subj_sessions["adas_Q1"]
+ df_subj_sessions["adas_Q4"]
+ df_subj_sessions["adas_Q7"]
+ df_subj_sessions["adas_Q8"]
+ df_subj_sessions["adas_Q9"]
) # / 45
df_subj_sessions["adas_language"] = (
df_subj_sessions["adas_Q2"]
+ df_subj_sessions["adas_Q5"]
+ df_subj_sessions["adas_Q10"]
+ df_subj_sessions["adas_Q11"]
+ df_subj_sessions["adas_Q12"]
) # / 25
df_subj_sessions["adas_praxis"] = (
df_subj_sessions["adas_Q3"] + df_subj_sessions["adas_Q6"]
) # / 10
df_subj_sessions["adas_concentration"] = df_subj_sessions["adas_Q13"] # / 5

df_subj_sessions = df_subj_sessions.fillna("n/a")

# compute the amyloid and ptau status
df_subj_sessions["a_stat"] = df_subj_sessions.apply(
lambda x: _compute_amyloid_status(
x[["adni_av45", "adni_pib", "adni_abeta"]].apply(
pd.to_numeric, errors="coerce"
)
),
axis=1,
)
df_subj_sessions["tau_stat"] = df_subj_sessions.apply(
lambda x: _compute_ptau_status(
x[["adni_ptau"]].apply(pd.to_numeric, errors="coerce")
),
axis=1,
)
for subject_path in bids_subjs_paths:
subject_path.mkdir(parents=True, exist_ok=True)
if subject_path.name == "conversion_info":
continue
df_tmp = df_subj_sessions[df_subj_sessions["RID"] == subject_path.name[12:]]
df_tmp.to_csv(
subject_path / f"{subject_path.name}_sessions.tsv",
sep="\t",
index=False,
encoding="utf-8",
)

Maybe not all of the ADAS scores are needed for building the sessions TSV? 

Matt

Matt Tharp

unread,
Jan 16, 2025, 10:13:15 AMJan 16
to Clinica
I thought about this some more and realized that ADNIMERGE does not yet contain ADNI4 information. Since ADNIMERGE seems to lag behind actual imaging availability, I was wondering if this scenario could also benefit from using ALL_IMG.csv as I've linked in another post, and finding a way to build sessions.tsv from that file instead (if possible, using the metadata from Advanced Image Search as the primary reference for building TSVs?)
Reply all
Reply to author
Forward
0 new messages