-
Notifications
You must be signed in to change notification settings - Fork 77
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
Key Error : APGEN1 #1294
Comments
Hi, thanks for reporting this issue ! Could you tell me first what OS you use, as well as the version of python and of clinica you are currently running ? Clinica does not support ADNI4 yet but I want to make sure there is no other issue first. You suppose well I think but we still need to fix it ^^ ! Best, |
Of course ! I use CentOS Linux release 7.6.1810 with python 3.9 and clinica version 0.7.5 ADNI love to change its information between 1, 2 and 3 so I imagine that 4 have some changes too ! If Clinica doesn't support ADNI4, maybe neuroimaging can't be converted ? Or clinica can use ADNI's CSV like ADNI1,2,3 ? |
Thanks for precisions ! First I would use a new python environment with the latest release of clinica since we are now using python 3.10 and clinica 0.8.4 (the instructions for installation are here). If you still have issues with converting data then it is probably due to changes in csv as you said. It will mainly break when trying to write metadata files (participants, scans, sessions tsv files) but the BIDS architecture will be there. Depending on what you want to do it could suffice while we fix this which is not planned yet. Let me know how it goes :-) |
Solution for ADNI to BIDS Conversion IssueHi, I encountered the same error ( Here’s the solution that worked for me:
import pandas as pd
# Path to the APOE results file
path = "your-path/APOERES_16Sep2024.csv"
# Read the CSV file
df = pd.read_csv(path)
# Get the position (index) of the 'GENOTYPE' column
genotype_index = df.columns.get_loc('GENOTYPE')
# Split the 'GENOTYPE' column into 'APGEN1' and 'APGEN2'
apgen = df['GENOTYPE'].str.split('/', expand=True)
apgen.columns = ['APGEN1', 'APGEN2']
# Drop the original 'GENOTYPE' column
df = df.drop(columns=['GENOTYPE'])
# Insert 'APGEN1' and 'APGEN2' at the position of the old 'GENOTYPE' column
for i, col in enumerate(apgen.columns):
df.insert(genotype_index + i, col, apgen[col])
# Save the modified DataFrame and replace the old file
df.to_csv(path, index=False)
With these changes, I was able to successfully convert the without errors. I hope this helps others facing the same issue. |
Thank you very much @GabrieleLozupone for your contribution ! I would advise to follow your suggestion till we change the source code to fix this issue (soon, hopefully 🤞). |
Thank you for your help ! It worked perfectly for .tsv ! I have one more error after that : INFO:Creating scans files... This file seems to not be very important but it's a problem. I checked and I have the .NII image with the good name and format so I don't understand why I have this error, maybe I can rerun ? |
Glad to hear the previous issue is resolved ! When you mean "the good name" do you mean "sub-ADNI031S4194_ses-M000_FLAIR_real.nii" ? |
Yes ! |
Are you still using your environment with python 3.9, clinica 0.7.5 ? ADNI-to-BIDS also require dcm2nix, do you know which version are you using ? |
Yes, I ask to update because I can't make it myself but it's not done. I have dcm2niix==1.0.20220715. I have scan files for few subjects but one failed and stop for the rest of subjects so I think it's maybe not the problem ? I try to rerun because internal connections between data and servers (not in the same place) can fail. |
Sometimes dcm2niix produces images with the suffix "_real". They are not BIDS compliant so clinica removes them after they have been written by dcm2niix. I tried the same set-up as you (same version of python, clinica, dcm2niix) but did not see anything wrong in this behavior so that is not the issue. Running again could indeed work, tell me if that changed anything. You can also try downloading the image data again. If this persists : do you know if this issue arises for only one subject or more ? Since the converter is going to remove these images anyway, you can remove the subject/session from your original data or use a subject list (see clinica documentation) without it. |
Rerun change nothing. I think I will have the same problem with others subjects (because I checked repertories and I have others _real suffix, for FLAIR). What is the difference between images with and without "_real" suffix ? Maybe I can rename it ? |
I followed your instruction, the issue of APGEN1 is resolved. However, now I am having the error as below: 2024-10-18 19:55:12,883:DEBUG:PET_TAU conversion done. I have double checked the directory but there is only one file in the CLinicalData Directory. However, When I searched on my machine with the name "APOERES". There are two files retreived but with the name "participant.csv" as indicated in the screenshot (I guess one for ADNI, and one for ABIDE and OASIS). |
Hello,
I used Clinica to convert ADNI to BIDS and I have a pandas error : "KeyError : APGEN1"
This error concern adni_to_bids.convert_clinical_data with participants_df = bids.create_participants_df() and more precisely value_to_read = file_to_read[participant_field_db[i]]
It's when participants.tsv are created and no tsv are generated in my case. I just download all ADNI data between ADNI 1 to ADNI 4 (on July 2024) et just run clinica without options (for all datas).
Do you have an idea why I have this error ? I suppose that one key isn't here in clinical data for ADNI but if we have a larger problem, I would like to submit it.
Thank you for your help !
The text was updated successfully, but these errors were encountered: