Perhaps a json-related dcm2bids error (version 3.0.1)

sorry if this is a dumb question, i was just getting the hang of dcm2bids and then i had to switch to a newer computer and install the new major changes dcm2bids

Summary of what happened:

error with recent dcm2bids, related to .jsons? was a pip install. versions and system in the pasted command and output below (also i’m running MacOS 13.5.1):

salvatoretorrisi@computername% dcm2bids -d subjectd/nestedDir/ -c $HOME/motion_config.json -p 001 -o outputBidsyDirTest
INFO    | --- dcm2bids start ---
INFO    | Running the following command: /opt/homebrew/bin/dcm2bids -d subjectd/nestedDir/ -c /Users/salvatoretorrisi/motion_config.json -p 001 -o outputBidsyDirTest
INFO    | OS version: macOS-13.5.1-arm64-arm-64bit
INFO    | Python version: 3.11.4 (main, Jul 25 2023, 17:36:13) [Clang 14.0.3 (clang-1403.0.22.14.1)]
INFO    | dcm2bids version: 3.0.1
INFO    | dcm2niix version: v1.0.20230411
INFO    | Checking for software update
INFO    | Currently using the latest version of dcm2bids.
INFO    | Currently using the latest version of dcm2niix.
INFO    | participant: sub-001
INFO    | config: /Users/salvatoretorrisi/motion_config.json
INFO    | BIDS directory: /Users/salvatoretorrisi/Desktop/MOTION/outputBidsyDir2
INFO    | Auto extract entities: False
INFO    | Validate BIDS: False

Traceback (most recent call last):
  File "/opt/homebrew/bin/dcm2bids", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dcm2bids/cli/dcm2bids.py", line 119, in main
    app = Dcm2BidsGen(**vars(args)).run()
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dcm2bids/dcm2bids_gen.py", line 51, in __init__
    self.config = load_json(valid_path(config, type="file"))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/dcm2bids/utils/io.py", line 18, in load_json
    data = json.load(f, object_pairs_hook=OrderedDict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 60 column 38 (char 2009)

Hi @stbmtx,

It is hard to debug this without your config file. Are you using a config that worked with a dcm2bids 2.X.X version? If so, it will not work with 3.X.X without modifications. See documentation here about how to change config files: How to upgrade - dcm2bids documentation

Best,
Steven

i think you’re right, it must be my config file. i tried to modify a 2.X.X version accordingly for a new dataset but i’m clearly messing something up. it’s attached, do you spot issues? how do you guys debug configs without also seeing all the raw dicoms? it would be nice to see a whole example config for the new 3.X.X version instead of just a list of updates.
motion_config.txt (2.6 KB)

note that i changed the suffix to “.txt” just to upload here

You should review the full documentation page, there is a nice tutorial with an example config here: First steps - dcm2bids documentation

We will get there if needed, but not worth looking into it until the config file syntax is all up to code.

Is this the config file associated with the original error message in the post?

Best,
Steven

Hi @stbmtx,

        "custom_entities": [
            "task-rest_AP"
        ],

That’s not going to be BIDS valid - it would need to be dir-AP. There are other similar instances that should be similarly addressed.

That doesn’t explain the error though, which implies something is wrong in line 60 (which looks fine to me at cursory glance), so I am wondering if this config was made after an attempt to make it 3.X.X compliant and after error in the original post.

Best,
Steven

motion_config.txt (3.1 KB)

ok i got it working now, attached
note that there are a couple warnings due to me forcing it to have “se” (spin echo) in the name, but to explain why and ask about alternatives is outside the scope of this thread, so i’ll just leave it for now

thank you @Steven for your help!!

1 Like