Hcp_pre_freesurfer can't find the data

Hi QuNex team,

I’m trying to process 10 subjects from HCPYA (HCP1200) as a test. I was able to run the container up till hcp_pre_freesurfer where I got an error that seems to be data linking issue:

---> ERROR: Could not find T1w image file. []
---> ERROR: The requested HCP processing mode is 'HCPStyleData', however, no T2w image was specified!
            Consider using LegacyStyleData processing mode.
---> WARNING: No distortion correction method specified.
---> Due to missing files session can not be processed.

This was the commmand qunex got:

qunex hcp_pre_freesurfer \
  --sessionsfolder="/home/selinali/Documents/HCPpipelines_workdir/sessions" \
  --overwrite="no" \
  --sessions="/home/selinali/Documents/HCPpipelines_workdir/processing/batch.txt" \
  --sessionids="100307_3T" \

Before this create_study, import_hcp, setup_hcp, and create_batch ran sucessfully.
(I had to manually loop through setup_hcp for each session, wasn’t sure if that would be an issue?)

I saw similar errors in this post but I’ve been onboarding HCPYA from scratch using /unpreprocessed. What might be the problem? Is there any configuration that needs to be set manually?

Thank you!
Selina




These are the setup files and command sequence:
batch.txt (61.7 KB)
parameters.txt (42.9 KB)
parameters_example.txt (43.5 KB)
sessions.txt (1.4 KB)
sessions.txt (1.4 KB)

### create study
qunex_container create_study \
		--studyfolder="${qdir}" \
		--container="${con}/qunex_suite-0.100.0.sif"

### import hcp
# from https://forum.qunex.yale.edu/t/resolved-import-hcp-ya-released-data/489/
qunex_container import_hcp \
	--sessionsfolder="${qdir}/sessions"  \
	--inbox="/home/selinali/Documents/study_folder_hcp_"  \
	--sessions="3T"  \
	--action="copy"  \
	--archive="leave"  \
	--nameformat="(?P<subject_id>[^/]+?)/unprocessed/(?P<session_name>.*?)/(?P<data>.*)"  \
	--hcplsname="hcpya" \
	--container="${con}/qunex_suite-0.100.0.sif"

### setup_hcp
foreach ID (101107 101309 101915 103111 103414 103818 105014 105115)
    cd ${qdir}/sessions/${ID}_3T; \
    qunex_container setup_hcp \
        --hcp_folderstructure="hcpya" \
        --container="${con}/qunex_suite-0.100.0.sif"
end

### create_batch
qunex_container create_batch \
	--sessionsfolder="${qdir}/sessions" \
	--paramfile="${qdir}/sessions/specs/parameters.txt" \
	--targetfile="${qdir}/processing/batch.txt" \
	--container="${con}/qunex_suite-0.100.0.sif"
# paramfile was taken from tutorial example: HCP001_parameters.txt

### hcp_pre_freesurfer
qunex_container hcp_pre_freesurfer \
	--sessionsfolder="${qdir}/sessions" \
	--batchfile="${qdir}/processing/batch.txt" \
	--overwrite="no" \
	--container="${con}/qunex_suite-0.100.0.sif"

Hi Selina,

Welcome to the QuNex forum. Sorry for the late reply, I was out of office. At a glance all looks good.

If you manually check the contents, are the files there. For example, do you have

.../sessions/101107_3T/hcpls/T1w_MPR1

And images inside:

.../sessions/100206_3T/nii

I recently processed the 100206_3T session myself. I am pasting the chain of commands below so we can see if something sticks out. I propose that you first try getting 1 session up and running with hcp_pre_freesurfer and then start at scale once we resolve that.

STUDY_FOLDER="/data/jure/qx_study"

qunex_container create_study \
  --studyfolder="${STUDY_FOLDER}" \
  --bind="/data:/data" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

qunex_container import_hcp \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --inbox="/data/archive/HCPYA" \
  --sessions="100206_3T" \
  --archive="leave" \
  --nameformat="(?P<subject_id>[^/]+?)/unprocessed/(?P<session_name>.*?)/(?P<data>.*)" \
  --hcplsname="hcpya" \
  --bind="/data:/data" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

# here you can run create batch before setup_hcp to the facilitate batch for setup_hcp over all sessions
qunex_container create_batch \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --paramfile="/data/specs/hcpya_parameters.txt" \
  --targetfile="${STUDY_FOLDER}/processing/batch.txt" \
  --bind="/data:/data" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

qunex_container setup_hcp \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --sessions="${STUDY_FOLDER}/processing/batch.txt" \
  --bind="/data:/data" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

qunex_container  hcp_pre_freesurfer \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --sessions="${STUDY_FOLDER}/processing/batch.txt" \
  --bind="/data:/data" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

To run this at scale now, just replacing --sessions="100206_3T" in the import command with a comma separated list of sessions should do the trick. Let me know how this goes.

Best, Jure

Hi Jure,

Thanks for sharing the commands, they’re very helpful! Pre_freesurfer is running now after changing the sessions name.

But there were some parameters I had to work around with - such as manually listing the sessions in setup_hcp and hcp_pre_freesurfer. If I use --session=<path to batch file> as in your command it throws me an error "No sessions specified to process. Please check your batch file, filtering options or sessionids parameter!".

Also I had to add these parameters to hcp_pre_freesurfer: "--hcp_unwarpdir="x" --hcp_seechospacing="0.00058" --hcp_t1samplespacing="0.0000074" --hcp_t2samplespacing="0.0000021" --hcp_seunwarpdir="x" ". I have these values in my parameters.txt but it doesn’t seem like they were detected. Is this normal?


Thank you so much for your time :blush:
Selina


List of commands

setenv STUDY_FOLDER "/export/home/selinali/Documents/HCPpipelines_workdir"
setenv QX_CONTAINERS "/export/home/selinali/Documents/qunex"
setenv rootdir "/export/home/selinali/Documents"
setenv PATH "${PATH}:${QX_CONTAINERS}"
rm -rf ${rootdir}/HPpipelines_workdir/

qunex_container create_study \
  --studyfolder="${STUDY_FOLDER}" \
   --bind="${rootdir}:${rootdir}" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

qunex_container import_hcp \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --inbox="/export/home/selinali/Documents/study_folder_hcp_" \
  --sessions="101107_3T,101107_3T,101309_3T,101915_3T,103111_3T,103414_3T,103818_3T,105014_3T,105115_3T" \
  --archive="leave" \
  --nameformat="(?P<subject_id>[^/]+?)/unprocessed/(?P<session_name>.*?)/(?P<data>.*)" \
  --hcplsname="hcpya" \
   --bind="${rootdir}:${rootdir}" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

# here you can run create batch before setup_hcp to the facilitate batch for setup_hcp over all sessions
qunex_container create_batch \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --paramfile="${QX_CONTAINERS}/data/parameters.txt" \
  --targetfile="${STUDY_FOLDER}/processing/batch.txt" \
  --bind="${rootdir}:${rootdir}" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

qunex_container setup_hcp \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --sessions="101107_3T,101107_3T,101309_3T,101915_3T,103111_3T,103414_3T,103818_3T,105014_3T,105115_3T" \
   --bind="${rootdir}:${rootdir}" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif"

qunex_container  hcp_pre_freesurfer \
  --sessionsfolder="${STUDY_FOLDER}/sessions" \
  --batchfile="${STUDY_FOLDER}/processing/batch.txt" \
  --sessions="101107_3T,101107_3T,101309_3T,101915_3T,103111_3T,103414_3T,103818_3T,105014_3T,105115_3T" \
  --bind="${rootdir}:${rootdir}" \
  --hcp_unwarpdir="x" --hcp_seechospacing="0.00058" --hcp_t1samplespacing="0.0000074" --hcp_t2samplespacing="0.0000021" --hcp_seunwarpdir="x" \
  --container="${QX_CONTAINERS}/qunex_suite-0.100.0.sif" 


Hi,

Can you upload the batch file so I can take a look at it.

If the parameters are in there, they should be detected and used. Yes, a workaround is to manually provide them, but it should work without this. At least in my case above it works perfectly fine. It seems like something might be wrong in the batch file.

Glad that things are running now though!

Best, Jure

Hi Jure,

Sorry for the late reply, I’ve attached my batch.txt if you could take a look at it.
batch.txt (58.3 KB)

Thank you,
Selina

Hi,

If the line starts with # it means it is not a real setting but just a comment (text). It gets ignored by QuNex. You used the template file without changing it. What is the most clean way is to remove the lines with parameters you do not need and for the parameters you do need, remove the # and the empty space behind it and set the value to what it needs to be. This way, parameter will be properly set from the batch file.

Best, Jure

Hi Jure,

Got it, that makes sense! I’ll try again removing the comments.

I ran through the FreeSurfer stages but had some trouble starting post-freesurfer processing… Seems like it’s not filling in the fmap magnitude and phase file paths.

Running HCP Pipelines command via QuNex:
/opt/HCP/HCPpipelines/fMRIVolume/GenericfMRIVolumeProcessingPipeline.sh
    --path="/home/selinali/Documents/HCPpipelines_workdir/sessions/103111_3T/hcp"
    --subject="103111_3T"
    --fmriname="BOLD_4"
    --fmritcs="/home/selinali/Documents/HCPpipelines_workdir/sessions/103111_3T/hcp/103111_3T/unprocessed/BOLD_4_RL/103111_3T_BOLD_4_RL.nii.gz"
    --fmriscout="NONE"
    --fmapmag="NONE"
    --fmapphase="NONE"
    --fmapcombined="NONE"...

Actually, I’m a little confused how session.txt and batch.txt are different. Are they doing the same job except one is for single session and the other is for multiple sessions?

Would you mind checking my sessions.txt as well?

session: 101107_3T
subject: 101107
hcpfs: /home/selinali/Documents/HCPpipelines_workdir/sessions/101107_3T/hcpls
raw_data: /home/selinali/Documents/HCPpipelines_workdir/sessions/101107_3T/nii
hcp: /home/selinali/Documents/HCPpipelines_workdir/sessions/101107_3T/hcp

hcpready: true

institution: NA
device: NA|NA|NA

01: FM-Magnitude        : FieldMap_Magnitude            : fm(1) : filename(FieldMap_Magnitude)
02: FM-Phase            : FieldMap_Phase                : fm(1) : filename(FieldMap_Phase)
03: T1w                 : T1w_MPR1                      : fm(1) : filename(T1w_MPR1)
04: T1w                 : T1w_MPR2                      : fm(1) : filename(T1w_MPR2)
05: T2w                 : T2w_SPC1                      : fm(1) : filename(T2w_SPC1)
06: T2w                 : T2w_SPC2                      : fm(1) : filename(T2w_SPC2)
07: SE-FM-LR            : SpinEchoFieldMap_LR           : se(1) : phenc(LR) : filename(SpinEchoFieldMap_LR)
08: SE-FM-RL            : SpinEchoFieldMap_RL           : se(1) : phenc(RL) : filename(SpinEchoFieldMap_RL)
09: boldref1:REST1      : rfMRI_REST1_LR_SBRef          : se(1) : phenc(LR) : filename(rfMRI_REST1_LR_SBRef)
10: bold1:REST1         : rfMRI_REST1_LR                : se(1) : phenc(LR) : filename(rfMRI_REST1_LR)
11: boldref2:REST1      : rfMRI_REST1_RL_SBRef          : se(1) : phenc(RL) : filename(rfMRI_REST1_RL_SBRef)
12: bold2:REST1         : rfMRI_REST1_RL                : se(1) : phenc(RL) : filename(rfMRI_REST1_RL)
13: boldref3:REST2      : rfMRI_REST2_LR_SBRef          : se(1) : phenc(LR) : filename(rfMRI_REST2_LR_SBRef)
14: bold3:REST2         : rfMRI_REST2_LR                : se(1) : phenc(LR) : filename(rfMRI_REST2_LR)
15: boldref4:REST2      : rfMRI_REST2_RL_SBRef          : se(1) : phenc(RL) : filename(rfMRI_REST2_RL_SBRef)
16: bold4:REST2         : rfMRI_REST2_RL                : se(1) : phenc(RL) : filename(rfMRI_REST2_RL)

Many thanks,
Selina

Hi,

The logic is that session.txt is info on the session level, while batch.txt is a concatenation of sessions. The batch files allows us to process many sessions (also in parallel) in a rapid fashion at scale. In the most common case the batch file simply contains all of the sessions. But there are scenarios when I might have multiple session files. For example, my study might have a 100 participants, out of the 100, 90 underwent the full acquisition, while with 10 participants the acquisition was stopped in the middle for some reason. Because of this I might need to treat and process these 10 sessions differently. To accommodate this, I might have 2 batch files, the main one for the 90 sessions and another one for the 10 “outliers”.

There are two session files. The first one is session.txt which gets generated when you import the data. This one includes the data that can be automatically extracted by QuNex from imaging data during the import process. For processing you then often need to inject additional information into these files. This is done with the create_session_info command through the mapping file and the output here is session_hcp.txt. So this file is the session.txt upgraded with additional information required by the HCP pipelines. So I can help you out, please provide the contents of session_hcp.txt for the above session and maybe also the mapping file you used in create_session_info.

Best, Jure