[RESOLVED] Updating Mapping?

Good evening

I am trying to update my mappings.txt file, is there an easier way to do this rather than going through a created batch.txt file and looking at what is missing?

Also, I noticed that different types of scans have been given the same mapping ID

---
# Generated by QuNex 0.99.2 on 2024-05-21_16.37.53.036462
#
session: 006_S_6689
subject: 006
dicom: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/006_S_6689/dicom
raw_data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/006_S_6689/nii
data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/006_S_6689/4dfp
hcp: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/006_S_6689/hcp
institution: UNIVERSITY of MICHIGAN Main
device: Philips Medical Systems|Ingenia
hcpready: true
10011:                :Axial fcMRI (EYES OPEN)
10011:                :Axial fcMRI (EYES OPEN) [1/2]
10012:                :Axial fcMRI (EYES OPEN) [2/2]
101 :bold1:rest      :Accelerated Sag IR-FSPGR
101 :bold1:rest      :Axial rsfMRI (Eyes Open) [1/2]
101 :bold1:rest      :Field Mapping [1/2]
102 :                :Axial rsfMRI (Eyes Open) [2/2]

---

How do I handle 101 :bold1:rest :Accelerated Sag IR-FSPGR and 101 :bold1:rest :Axial rsfMRI (Eyes Open) [1/2] separately? Or making sure they are not both given 101

Finally, am I correct in assuming the [1/2] is because the subject has multiple session? Will this cause any issues later on?

Thank you, Scott

Hi,

This is how it goes:

  1. You create a QuNex study with create_study.
  2. You onboard the data with import commands (import_dicom, import_bids, import_hcp).
  3. You inject additional imaging information with create_session_info. This where the mapping file is used. So if your mapping is not correct, you fix it and rerun create_session_info. When acquisitions across sessions are not consistent you sometimes need multiple mapping files (each one for used acquisition protocol/sequence). Output of this step is session_hcp.txt which is session.txt injected with additional data you provided.
  4. You run create_batch to compile the batch file. A batch file is a combination of parmaeters (the parmaeters file) and session info files (session_hcp.txt). So the best way is to get the mapping right so you do not have to manually fix session_hcp.txt or the batch file.

The [1/2] entries denote that there are multiple entries/images belonging to the same acquisition step/modality. Whether this is correct or not needs to be determined by you, I do not have the info about the acquisition protocol.

Best, Jure

Hi Jure

Can you elaborate on multiple mapping files.
Do I create one for each subject? Or is it more based on the device/institution?
How do I differentiate between the mapping files? Are they store differently?

Regarding the multiple entries/images, will I get multiple outputs or do they get combined/average and only one output per subject?

Thank you, Scott

Hi Scott,

If data acquisition is well executed you need a single mapping file that you use for all sessions. Again, the mapping file is used ONLY for the create_session_info command. If there is a mismatch between acquisition across session, e.g. different order, different naming …, you most likely need a different mapping file for sessions that were acquired differently. You differentiate between them by storing them under different names and then providing different paths as inputs to create_session_info.

Mapping files are traditionally prepared by looking at session.txt for each session once the data is onboarded.

At a glance your mapping file is wrong as the example you sent for 006_S_6689 is all over the place. You have 3 images with the same image number (101), the same tag (bold1:rest), but different description. Please read this to get more information: Preparing a study-level mapping file for QuNex workflows — QuNex documentation.

Best, Jure

Hi Jure

You are of course correct, I was looking at the data elsewhere and had applied a sort, so order got messed up, below are some correct examples.
41 should be bold:rest

# Generated by QuNex 0.99.2 on 2024-05-21_16.37.53.287229
#
session: 022_S_6013
subject: 022
dicom: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/022_S_6013/dicom
raw_data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/022_S_6013/nii
data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/022_S_6013/4dfp
hcp: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/022_S_6013/hcp
institution: HUP
device: SIEMENS|TrioTim
hcpready: true
31  :T2w             :Accelerated Sagittal MPRAGE
41  :T2w             :Axial fcMRI (EYES OPEN)
61  :                :Sagittal 3D Accelerated MPRAGE
131 :                :Axial rsfMRI (EYES OPEN)

---

Here 31 is still for an Accelerated Saittal, but IR-FSPGR and not MPRAGE

# Generated by QuNex 0.99.2 on 2024-05-21_16.37.52.998445
#
session: 027_S_6733
subject: 027
dicom: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/027_S_6733/dicom
raw_data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/027_S_6733/nii
data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/027_S_6733/4dfp
hcp: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/027_S_6733/hcp
institution: UIRR
device: GE MEDICAL SYSTEMS|DISCOVERY MR750
hcpready: true
31  :T2w             :Accelerated Sagittal IR-FSPGR [1/2]
32  :                :Accelerated Sagittal IR-FSPGR [2/2]
81  :                :Axial rsfMRI (Eyes Open)
91  :bold1:rest      :Axial rsfMRI (Eyes Open)

---

Not sure what happened with this one, as I would have expected both Accelerated Sag IR-FSPGR to be these same code.

# Generated by QuNex 0.99.2 on 2024-05-21_16.37.52.974601
#
session: 129_S_6784
subject: 129
dicom: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6784/dicom
raw_data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6784/nii
data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6784/4dfp
hcp: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6784/hcp
institution: Banner Alzheimers Institute
device: GE MEDICAL SYSTEMS|DISCOVERY MR750
hcpready: true
31  :T2w             :Accelerated Sag IR-FSPGR [1/2]
32  :                :Accelerated Sag IR-FSPGR [2/2]
81  :                :Axial rsfMRI (Eyes Open) [1/2]
82  :                :Axial rsfMRI (Eyes Open) [2/2]
101 :bold1:rest      :Accelerated Sag IR-FSPGR
141 :                :Accelerated Sag IR-FSPGR

---

This one, why are both Axial rsfMRI (Eyes Open) not the same code, or 81 and 82?

# Generated by QuNex 0.99.2 on 2024-05-21_16.37.53.271289
#
session: 129_S_6763
subject: 129
dicom: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6763/dicom
raw_data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6763/nii
data: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6763/4dfp
hcp: /gpfs/home/tqh20wsu/scratch/qunex/ADNI_AD/sessions/129_S_6763/hcp
institution: Banner Alzheimers Institute
device: GE MEDICAL SYSTEMS|DISCOVERY MR750
hcpready: true
31  :T2w             :Accelerated Sag IR-FSPGR
41  :T2w             :Accelerated Sag IR-FSPGR
81  :                :Axial rsfMRI (Eyes Open)
91  :bold1:rest      :Axial rsfMRI (Eyes Open)
111 :bold2:rest      :Accelerated Sag IR-FSPGR

---

Am I able to do something like this in mappings.txt?
Axial fcMRI (EYES OPEN) => bold:rest
If 41 is going to be linked to both Axial fcMRI (EYES OPEN) and Accelerated Sag IR-FSPGR do I need to run create_session_info multpile times with different mapping files? I assume by splitting the subjects by institution. device or some other method.
If I do this is batch.txt updated or replaced?
Can I update batch.txt manually?

Looking at the mappings link, can I do this for the above?

session: 022_S_6013
...
31  :T2w             :Accelerated Sagittal MPRAGE
41  :bold1:res       :Axial fcMRI (EYES OPEN)
61  :T2w             :Sagittal 3D Accelerated MPRAGE
131 :bold1:res       :Axial rsfMRI (EYES OPEN)

session: 027_S_6733
...
31  :T2w             :Accelerated Sagittal IR-FSPGR [1/2]
32  :T2w             :Accelerated Sagittal IR-FSPGR [2/2]
81  :bold1:rest      :Axial rsfMRI (Eyes Open)
91  :bold1:rest      :Axial rsfMRI (Eyes Open)

session: 129_S_6784
...
31  :T2w             :Accelerated Sag IR-FSPGR [1/2]
32  :T2w             :Accelerated Sag IR-FSPGR [2/2]
81  :bold1:rest      :Axial rsfMRI (Eyes Open) [1/2]
82  :bold1:rest      :Axial rsfMRI (Eyes Open) [2/2]
101 :T2w             :Accelerated Sag IR-FSPGR
141 :T2w             :Accelerated Sag IR-FSPGR

session: 129_S_6763
31  :T2w             :Accelerated Sag IR-FSPGR
41  :T2w             :Accelerated Sag IR-FSPGR
81  :bold1:rest      :Axial rsfMRI (Eyes Open)
91  :bold1:rest      :Axial rsfMRI (Eyes Open)
111 :T2w             :Accelerated Sag IR-FSPGR

Or is it better to do it this way?

Accelerated Sag IR-FSPGR [1/2] =>      T2w
Accelerated Sag IR-FSPGR [2/2] =>      T2w
Axial rsfMRI (Eyes Open) [1/2] =>      bold1:rest
Axial rsfMRI (Eyes Open) [2/2] =>      bold1:rest
Accelerated Sag IR-FSPGR =>            T2w
Axial rsfMRI (Eyes Open) =>            bold1:rest
Accelerated Sagittal MPRAGE =>         T2w
Axial fcMRI (EYES OPEN) =>             bold1:rest
Sagittal 3D Accelerated MPRAGE =>      T2w
Accelerated Sagittal IR-FSPGR [1/2] => T2w
Accelerated Sagittal IR-FSPGR [2/2] => T2w

Thank you, Scott

1/ The most transparent and reproducible way to fix this is to rerun create_session_info. Like you proposed at the end, you can build one, larger mapping file that covers all cases (this is the norm and it can usually be done).

If things are really messy and this does not work, we sometimes need to use multiple mapping files, one for each subset of sessions. There, you can group sessions so that the same mapping file is applied to the sessions that it works for:

qunex_container create_session_info \
    --sessionsfolder="${STUDY_FOLDER}/sessions" \
    --sessions="${SESSIONS}" \
    --mapping="${INPUT_MAPPING_FILE}" \
    --container="${QUNEX_CONTAINER}"

Just provide a different mapping file (${INPUT_MAPPING_FILE}) and a different comma separated list of sessions (${SESSIONS}) for each run of the command. And a different mapping file will be applied to each subset of sessions. You follow that by the traditional chain of commands, set --overwrite=yes for certain commands to overwrite previous results (e.g., the batch file).

Alternatively, you can manually sort out the batch file or session_hcp.txt files and use those. But this is not transparent and reproducible as your manual edits are not tracked anywhere.


2/ You can probably make the content of the mapping file you posted below even more compact. Not 100% this will work as I do not have full insights into your data, but try:

Accelerated Sag IR-FSPGR => T2w
Accelerated Sagittal IR-FSPGR => T2w
Accelerated Sagittal MPRAGE => T2w
Sagittal 3D Accelerated MPRAGE => T2w
Axial rsfMRI (Eyes Open) => bold:rest
Axial fcMRI (EYES OPEN) => bold:rest

My only question here is, what happened with T1w?

Thank you Jure.

Maybe I mean T1w (double checked and they are T1 weighted images) as I thought from the parameters.txt file we don’t need/use both T1w and T2w as we’re using the LegacyStyleData.

_hcp_processing_mode      : LegacyStyleData     # ... Controls whether the HCP acquisition and processing guidelines should be treated as requirements (HCPStyleData) or if additional processing functionality is allowed (LegacyStyleData).
_hcp_t2                    : NONE               # ... whether T2 image is present - anything or NONE.

So am I ok using just T1w and rsfMRI?

Thank you again, Scott

Yes, you need T1w. For legacy style datasets T2w is missing.

Best, Jure