poldracklab / fitlins

Fit Linear Models to BIDS Datasets
https://fitlins.readthedocs.io
Apache License 2.0
76 stars 32 forks source link

KeyError: 'trial_type' #330

Closed vogelbac closed 2 years ago

vogelbac commented 2 years ago

Hey got the problem KeyError: 'trial_type'

Captured warning (<class 'FutureWarning'>): Fetchers from the nilearn.datasets module will be updated in version 0.9 to return python strings instead of bytes and Pandas dataframes instead of Numpy arrays.
Traceback (most recent call last):
  File "/opt/miniconda-latest/envs/neuro/bin/fitlins", line 8, in <module>
    sys.exit(main())
  File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/cli/run.py", line 294, in main
    sys.exit(run_fitlins(sys.argv[1:]))
  File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/cli/run.py", line 259, in run_fitlins
    estimator=opts.estimator, errorts=opts.error_ts
  File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/workflows/base.py", line 26, in init_fitlins_wf
    model_dict = specs.run().outputs.model_spec
  File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 398, in run
    runtime = self._run_interface(runtime)
  File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/interfaces/bids.py", line 123, in _run_interface
    models = auto_model(layout)
  File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/bids/analysis/auto_model.py", line 67, in auto_model
    evs.extend(n.variables['trial_type'].values.values)

I use the docker version latest of fitlins. I tried to update my model file regarding the google docs file. But i still get the error. If you need more just let me know.

effigies commented 2 years ago

Hi, can you provide the full command you used, as well as the version of FitLins?

vogelbac commented 2 years ago

The command: docker run --rm -it -v /home/g0rella/Desktop/SFB:/bids:ro -v /home/g0rella/Desktop/SFB/derivatives/fmriprep:/prep:ro -v /home/g0rella/Desktop/SFB/derivatives:/out poldracklab/fitlins:master /bids /out dataset -d /prep The version is poldracklab/fitlins latest cf57f64375b3

effigies commented 2 years ago

poldracklab/fitlins:master Can you try using a released version, such as 0.9.2? I don't really recommend using :master unless you have a specific need for something that's been since the last version, and there's no way to tie old :master hashes to git commits, so I can't tell what version you're working from.

vogelbac commented 2 years ago

I am sorry I used the :latest and there raised the error and then i tried the master, to see if it is fixed (newer version) this was my fault.

docker run --rm -it -v /home/g0rella/Desktop/SFB:/bids:ro -v /home/g0rella/Desktop/SFB/derivatives/fmriprep:/prep:ro -v /home/g0rella/Desktop/SFB/derivatives:/out poldracklab/fitlins:latest /bids /out dataset -d /prep

Captured warning (<class 'FutureWarning'>): Fetchers from the nilearn.datasets module will be updated in version 0.9 to return python strings instead of bytes and Pandas dataframes instead of Numpy arrays. 220113-14:49:31,140 nipype.utils WARNING: A newer version (1.7.0) of nipy/nipype is available. You are using 1.6.1 Traceback (most recent call last): File "/opt/miniconda-latest/envs/neuro/bin/fitlins", line 8, in sys.exit(main()) File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/cli/run.py", line 294, in main sys.exit(run_fitlins(sys.argv[1:])) File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/cli/run.py", line 259, in run_fitlins estimator=opts.estimator, errorts=opts.error_ts File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/workflows/base.py", line 26, in init_fitlins_wf model_dict = specs.run().outputs.model_spec File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/nipype/interfaces/base/core.py", line 428, in run runtime = self._run_interface(runtime) File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/fitlins/interfaces/bids.py", line 123, in _run_interface models = auto_model(layout) File "/opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/bids/analysis/auto_model.py", line 67, in auto_model evs.extend(n.variables['trial_type'].values.values) KeyError: 'trial_type'

effigies commented 2 years ago

Okay. Could you share a listing (ideally tree) of /home/g0rella/Desktop/SFB?

So for the auto-model, it should just give you the beta estimates for each value in the trial_type column of events.tsv, per-run (it won't try to combine). If you have any BOLD series that are missing this column (such as a resting state scan), that's likely the cause of the problem.

vogelbac commented 2 years ago

For sure tree_folder.txt

vogelbac commented 2 years ago

I see the problem regarding the value trial_type for the resting state if it is not set. But i specify in the model.json file the "task" which should be used so it should not look after the resting state events.tsv files?

effigies commented 2 years ago

I don't see a model file being specified in your command line. You might want --model models/model-001_smdl.json. We will also automatically pick up models/model-default_smdl.json.

vogelbac commented 2 years ago

The usage of the --model helped to solve this problem.