We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
model: JSON to dict modified key values for transformation
In ` Replace` transformation, you specify as a dict which variables to transform.

e.g.:

```
{'LIKELY': "5"}
```

However, the parser from JSON to dict to convert BIDS Stats Models modifies keys to lower case, which in the case of specific case sensitive values modifies the transformation itself.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bids/utils.py`
Content:
```
1 """ Utility functions. """
2 
3 import re
4 import os
5 
6 
7 def listify(obj):
8     ''' Wraps all non-list or tuple objects in a list; provides a simple way
9     to accept flexible arguments. '''
10     return obj if isinstance(obj, (list, tuple, type(None))) else [obj]
11 
12 
13 def matches_entities(obj, entities, strict=False):
14     ''' Checks whether an object's entities match the input. '''
15     if strict and set(obj.entities.keys()) != set(entities.keys()):
16         return False
17 
18     comm_ents = list(set(obj.entities.keys()) & set(entities.keys()))
19     for k in comm_ents:
20         current = obj.entities[k]
21         target = entities[k]
22         if isinstance(target, (list, tuple)):
23             if current not in target:
24                 return False
25         elif current != target:
26             return False
27     return True
28 
29 
30 def natural_sort(l, field=None):
31     '''
32     based on snippet found at http://stackoverflow.com/a/4836734/2445984
33     '''
34     convert = lambda text: int(text) if text.isdigit() else text.lower()
35 
36     def alphanum_key(key):
37         if field is not None:
38             key = getattr(key, field)
39         if not isinstance(key, str):
40             key = str(key)
41         return [convert(c) for c in re.split('([0-9]+)', key)]
42     return sorted(l, key=alphanum_key)
43 
44 
45 def convert_JSON(j):
46     """ Recursively convert CamelCase keys to snake_case.
47     From: https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
48     """
49 
50     def camel_to_snake(s):
51         a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
52         return a.sub(r'_\1', s).lower()
53 
54     def convertArray(a):
55         newArr = []
56         for i in a:
57             if isinstance(i,list):
58                 newArr.append(convertArray(i))
59             elif isinstance(i, dict):
60                 newArr.append(convert_JSON(i))
61             else:
62                 newArr.append(i)
63         return newArr
64 
65     out = {}
66     for k, value in j.items():
67         newK = camel_to_snake(k)
68 
69         if isinstance(value, dict):
70             out[newK] = convert_JSON(value)
71         elif isinstance(value, list):
72             out[newK] = convertArray(value)
73         else:
74             out[newK] = value
75 
76     return out
77 
78 
79 def splitext(path):
80     """splitext for paths with directories that may contain dots.
81     From https://stackoverflow.com/questions/5930036/separating-file-extensions-using-python-os-path-module"""
82     li = []
83     path_without_extensions = os.path.join(os.path.dirname(path),
84         os.path.basename(path).split(os.extsep)[0])
85     extensions = os.path.basename(path).split(os.extsep)[1:]
86     li.append(path_without_extensions)
87     # li.append(extensions) if you want extensions in another list inside the list that is returned.
88     li.extend(extensions)
89     return li
90 
91 
92 def make_bidsfile(filename):
93     """Create a BIDSFile instance of the appropriate class. """
94     from .layout import models
95 
96     patt = re.compile("[._]*[a-zA-Z0-9]*?\\.([^/\\\\]+)$")
97     m = re.search(patt, filename)
98 
99     ext = None if not m else m.group(1)
100 
101     if ext in ['nii', 'nii.gz']:
102         cls = 'BIDSImageFile'
103     elif ext in ['tsv', 'tsv.gz']:
104         cls = 'BIDSDataFile'
105     elif ext == 'json':
106         cls = 'BIDSJSONFile'
107     else:
108         cls = 'BIDSFile'
109 
110     Cls = getattr(models, cls)
111     return Cls(filename)
112
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/bids/utils.py b/bids/utils.py
--- a/bids/utils.py
+++ b/bids/utils.py
@@ -44,9 +44,10 @@
 
 def convert_JSON(j):
     """ Recursively convert CamelCase keys to snake_case.
-    From: https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
+    From: https://stackoverflow.com/questions/17156078/
+    converting-identifier-naming-between-camelcase-and-
+    underscores-during-json-seria
     """
-
     def camel_to_snake(s):
         a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
         return a.sub(r'_\1', s).lower()
@@ -54,7 +55,7 @@
     def convertArray(a):
         newArr = []
         for i in a:
-            if isinstance(i,list):
+            if isinstance(i, list):
                 newArr.append(convertArray(i))
             elif isinstance(i, dict):
                 newArr.append(convert_JSON(i))
@@ -66,7 +67,8 @@
     for k, value in j.items():
         newK = camel_to_snake(k)
 
-        if isinstance(value, dict):
+        # Replace transformation uses a dict, so skip lower-casing
+        if isinstance(value, dict) and k != 'Replace':
             out[newK] = convert_JSON(value)
         elif isinstance(value, list):
             out[newK] = convertArray(value)

{"golden_diff": "diff --git a/bids/utils.py b/bids/utils.py\n--- a/bids/utils.py\n+++ b/bids/utils.py\n@@ -44,9 +44,10 @@\n \n def convert_JSON(j):\n     \"\"\" Recursively convert CamelCase keys to snake_case.\n-    From: https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria\n+    From: https://stackoverflow.com/questions/17156078/\n+    converting-identifier-naming-between-camelcase-and-\n+    underscores-during-json-seria\n     \"\"\"\n-\n     def camel_to_snake(s):\n         a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')\n         return a.sub(r'_\\1', s).lower()\n@@ -54,7 +55,7 @@\n     def convertArray(a):\n         newArr = []\n         for i in a:\n-            if isinstance(i,list):\n+            if isinstance(i, list):\n                 newArr.append(convertArray(i))\n             elif isinstance(i, dict):\n                 newArr.append(convert_JSON(i))\n@@ -66,7 +67,8 @@\n     for k, value in j.items():\n         newK = camel_to_snake(k)\n \n-        if isinstance(value, dict):\n+        # Replace transformation uses a dict, so skip lower-casing\n+        if isinstance(value, dict) and k != 'Replace':\n             out[newK] = convert_JSON(value)\n         elif isinstance(value, list):\n             out[newK] = convertArray(value)\n", "issue": "model: JSON to dict modified key values for transformation\nIn ` Replace` transformation, you specify as a dict which variables to transform.\r\n\r\ne.g.:\r\n\r\n```\r\n{'LIKELY': \"5\"}\r\n```\r\n\r\nHowever, the parser from JSON to dict to convert BIDS Stats Models modifies keys to lower case, which in the case of specific case sensitive values modifies the transformation itself.\n", "before_files": [{"content": "\"\"\" Utility functions. \"\"\"\n\nimport re\nimport os\n\n\ndef listify(obj):\n    ''' Wraps all non-list or tuple objects in a list; provides a simple way\n    to accept flexible arguments. '''\n    return obj if isinstance(obj, (list, tuple, type(None))) else [obj]\n\n\ndef matches_entities(obj, entities, strict=False):\n    ''' Checks whether an object's entities match the input. '''\n    if strict and set(obj.entities.keys()) != set(entities.keys()):\n        return False\n\n    comm_ents = list(set(obj.entities.keys()) & set(entities.keys()))\n    for k in comm_ents:\n        current = obj.entities[k]\n        target = entities[k]\n        if isinstance(target, (list, tuple)):\n            if current not in target:\n                return False\n        elif current != target:\n            return False\n    return True\n\n\ndef natural_sort(l, field=None):\n    '''\n    based on snippet found at http://stackoverflow.com/a/4836734/2445984\n    '''\n    convert = lambda text: int(text) if text.isdigit() else text.lower()\n\n    def alphanum_key(key):\n        if field is not None:\n            key = getattr(key, field)\n        if not isinstance(key, str):\n            key = str(key)\n        return [convert(c) for c in re.split('([0-9]+)', key)]\n    return sorted(l, key=alphanum_key)\n\n\ndef convert_JSON(j):\n    \"\"\" Recursively convert CamelCase keys to snake_case.\n    From: https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria\n    \"\"\"\n\n    def camel_to_snake(s):\n        a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')\n        return a.sub(r'_\\1', s).lower()\n\n    def convertArray(a):\n        newArr = []\n        for i in a:\n            if isinstance(i,list):\n                newArr.append(convertArray(i))\n            elif isinstance(i, dict):\n                newArr.append(convert_JSON(i))\n            else:\n                newArr.append(i)\n        return newArr\n\n    out = {}\n    for k, value in j.items():\n        newK = camel_to_snake(k)\n\n        if isinstance(value, dict):\n            out[newK] = convert_JSON(value)\n        elif isinstance(value, list):\n            out[newK] = convertArray(value)\n        else:\n            out[newK] = value\n\n    return out\n\n\ndef splitext(path):\n    \"\"\"splitext for paths with directories that may contain dots.\n    From https://stackoverflow.com/questions/5930036/separating-file-extensions-using-python-os-path-module\"\"\"\n    li = []\n    path_without_extensions = os.path.join(os.path.dirname(path),\n        os.path.basename(path).split(os.extsep)[0])\n    extensions = os.path.basename(path).split(os.extsep)[1:]\n    li.append(path_without_extensions)\n    # li.append(extensions) if you want extensions in another list inside the list that is returned.\n    li.extend(extensions)\n    return li\n\n\ndef make_bidsfile(filename):\n    \"\"\"Create a BIDSFile instance of the appropriate class. \"\"\"\n    from .layout import models\n\n    patt = re.compile(\"[._]*[a-zA-Z0-9]*?\\\\.([^/\\\\\\\\]+)$\")\n    m = re.search(patt, filename)\n\n    ext = None if not m else m.group(1)\n\n    if ext in ['nii', 'nii.gz']:\n        cls = 'BIDSImageFile'\n    elif ext in ['tsv', 'tsv.gz']:\n        cls = 'BIDSDataFile'\n    elif ext == 'json':\n        cls = 'BIDSJSONFile'\n    else:\n        cls = 'BIDSFile'\n\n    Cls = getattr(models, cls)\n    return Cls(filename)\n", "path": "bids/utils.py"}], "after_files": [{"content": "\"\"\" Utility functions. \"\"\"\n\nimport re\nimport os\n\n\ndef listify(obj):\n    ''' Wraps all non-list or tuple objects in a list; provides a simple way\n    to accept flexible arguments. '''\n    return obj if isinstance(obj, (list, tuple, type(None))) else [obj]\n\n\ndef matches_entities(obj, entities, strict=False):\n    ''' Checks whether an object's entities match the input. '''\n    if strict and set(obj.entities.keys()) != set(entities.keys()):\n        return False\n\n    comm_ents = list(set(obj.entities.keys()) & set(entities.keys()))\n    for k in comm_ents:\n        current = obj.entities[k]\n        target = entities[k]\n        if isinstance(target, (list, tuple)):\n            if current not in target:\n                return False\n        elif current != target:\n            return False\n    return True\n\n\ndef natural_sort(l, field=None):\n    '''\n    based on snippet found at http://stackoverflow.com/a/4836734/2445984\n    '''\n    convert = lambda text: int(text) if text.isdigit() else text.lower()\n\n    def alphanum_key(key):\n        if field is not None:\n            key = getattr(key, field)\n        if not isinstance(key, str):\n            key = str(key)\n        return [convert(c) for c in re.split('([0-9]+)', key)]\n    return sorted(l, key=alphanum_key)\n\n\ndef convert_JSON(j):\n    \"\"\" Recursively convert CamelCase keys to snake_case.\n    From: https://stackoverflow.com/questions/17156078/\n    converting-identifier-naming-between-camelcase-and-\n    underscores-during-json-seria\n    \"\"\"\n    def camel_to_snake(s):\n        a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')\n        return a.sub(r'_\\1', s).lower()\n\n    def convertArray(a):\n        newArr = []\n        for i in a:\n            if isinstance(i, list):\n                newArr.append(convertArray(i))\n            elif isinstance(i, dict):\n                newArr.append(convert_JSON(i))\n            else:\n                newArr.append(i)\n        return newArr\n\n    out = {}\n    for k, value in j.items():\n        newK = camel_to_snake(k)\n\n        # Replace transformation uses a dict, so skip lower-casing\n        if isinstance(value, dict) and k != 'Replace':\n            out[newK] = convert_JSON(value)\n        elif isinstance(value, list):\n            out[newK] = convertArray(value)\n        else:\n            out[newK] = value\n\n    return out\n\n\ndef splitext(path):\n    \"\"\"splitext for paths with directories that may contain dots.\n    From https://stackoverflow.com/questions/5930036/separating-file-extensions-using-python-os-path-module\"\"\"\n    li = []\n    path_without_extensions = os.path.join(os.path.dirname(path),\n        os.path.basename(path).split(os.extsep)[0])\n    extensions = os.path.basename(path).split(os.extsep)[1:]\n    li.append(path_without_extensions)\n    # li.append(extensions) if you want extensions in another list inside the list that is returned.\n    li.extend(extensions)\n    return li\n\n\ndef make_bidsfile(filename):\n    \"\"\"Create a BIDSFile instance of the appropriate class. \"\"\"\n    from .layout import models\n\n    patt = re.compile(\"[._]*[a-zA-Z0-9]*?\\\\.([^/\\\\\\\\]+)$\")\n    m = re.search(patt, filename)\n\n    ext = None if not m else m.group(1)\n\n    if ext in ['nii', 'nii.gz']:\n        cls = 'BIDSImageFile'\n    elif ext in ['tsv', 'tsv.gz']:\n        cls = 'BIDSDataFile'\n    elif ext == 'json':\n        cls = 'BIDSJSONFile'\n    else:\n        cls = 'BIDSFile'\n\n    Cls = getattr(models, cls)\n    return Cls(filename)\n", "path": "bids/utils.py"}]}