prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add center cropping
  **Is your feature request related to a problem? Please describe.**
  We do not have any mechanism to perform cropping, which is important for certain DL training problems.
  
  **Describe the solution you'd like**
  Expose the [cropping functionality in TorchIO](https://torchio.readthedocs.io/transforms/preprocessing.html?highlight=crop#torchio.transforms.Crop) as a preprocessing mechanism.
  
  **Describe alternatives you've considered**
  N.A.
  
  **Additional context**
  Requested by @Geeks-Sid for SBU-TIL.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `GANDLF/data/preprocessing/__init__.py`
  Content:
  ```
  1 from .crop_zero_planes import CropExternalZeroplanes
  2 from .non_zero_normalize import NonZeroNormalizeOnMaskedRegion
  3 from .threshold_and_clip import (
  4     threshold_transform,
  5     clip_transform,
  6 )
  7 from .normalize_rgb import (
  8     normalize_by_val_transform,
  9     normalize_imagenet_transform,
  10     normalize_standardize_transform,
  11     normalize_div_by_255_transform,
  12 )
  13 
  14 from torchio.transforms import (
  15     ZNormalization,
  16     ToCanonical,
  17 )
  18 
  19 
  20 def positive_voxel_mask(image):
  21     return image > 0
  22 
  23 
  24 def nonzero_voxel_mask(image):
  25     return image != 0
  26 
  27 
  28 def to_canonical_transform(parameters):
  29     return ToCanonical()
  30 
  31 
  32 # defining dict for pre-processing - key is the string and the value is the transform object
  33 global_preprocessing_dict = {
  34     "to_canonical": to_canonical_transform,
  35     "threshold": threshold_transform,
  36     "clip": clip_transform,
  37     "clamp": clip_transform,
  38     "crop_external_zero_planes": CropExternalZeroplanes,
  39     "normalize_by_val": normalize_by_val_transform,
  40     "normalize_imagenet": normalize_imagenet_transform,
  41     "normalize_standardize": normalize_standardize_transform,
  42     "normalize_div_by_255": normalize_div_by_255_transform,
  43     "normalize": ZNormalization(),
  44     "normalize_positive": ZNormalization(masking_method=positive_voxel_mask),
  45     "normalize_nonZero": ZNormalization(masking_method=nonzero_voxel_mask),
  46     "normalize_nonZero_masked": NonZeroNormalizeOnMaskedRegion(),
  47 }
  48
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/GANDLF/data/preprocessing/__init__.py b/GANDLF/data/preprocessing/__init__.py
  --- a/GANDLF/data/preprocessing/__init__.py
  +++ b/GANDLF/data/preprocessing/__init__.py
  @@ -14,6 +14,8 @@
   from torchio.transforms import (
       ZNormalization,
       ToCanonical,
  +    Crop,
  +    CropOrPad,
   )
   
   
  @@ -29,6 +31,14 @@
       return ToCanonical()
   
   
  +def crop_transform(patch_size):
  +    return Crop(patch_size)
  +
  +
  +def centercrop_transform(patch_size):
  +    return CropOrPad(target_shape=patch_size)
  +
  +
   # defining dict for pre-processing - key is the string and the value is the transform object
   global_preprocessing_dict = {
       "to_canonical": to_canonical_transform,
  @@ -36,6 +46,8 @@
       "clip": clip_transform,
       "clamp": clip_transform,
       "crop_external_zero_planes": CropExternalZeroplanes,
  +    "crop": crop_transform,
  +    "centercrop": centercrop_transform,
       "normalize_by_val": normalize_by_val_transform,
       "normalize_imagenet": normalize_imagenet_transform,
       "normalize_standardize": normalize_standardize_transform,
  
verification_info: {"golden_diff": "diff --git a/GANDLF/data/preprocessing/__init__.py b/GANDLF/data/preprocessing/__init__.py\n--- a/GANDLF/data/preprocessing/__init__.py\n+++ b/GANDLF/data/preprocessing/__init__.py\n@@ -14,6 +14,8 @@\n from torchio.transforms import (\n     ZNormalization,\n     ToCanonical,\n+    Crop,\n+    CropOrPad,\n )\n \n \n@@ -29,6 +31,14 @@\n     return ToCanonical()\n \n \n+def crop_transform(patch_size):\n+    return Crop(patch_size)\n+\n+\n+def centercrop_transform(patch_size):\n+    return CropOrPad(target_shape=patch_size)\n+\n+\n # defining dict for pre-processing - key is the string and the value is the transform object\n global_preprocessing_dict = {\n     \"to_canonical\": to_canonical_transform,\n@@ -36,6 +46,8 @@\n     \"clip\": clip_transform,\n     \"clamp\": clip_transform,\n     \"crop_external_zero_planes\": CropExternalZeroplanes,\n+    \"crop\": crop_transform,\n+    \"centercrop\": centercrop_transform,\n     \"normalize_by_val\": normalize_by_val_transform,\n     \"normalize_imagenet\": normalize_imagenet_transform,\n     \"normalize_standardize\": normalize_standardize_transform,\n", "issue": "Add center cropping\n**Is your feature request related to a problem? Please describe.**\r\nWe do not have any mechanism to perform cropping, which is important for certain DL training problems.\r\n\r\n**Describe the solution you'd like**\r\nExpose the [cropping functionality in TorchIO](https://torchio.readthedocs.io/transforms/preprocessing.html?highlight=crop#torchio.transforms.Crop) as a preprocessing mechanism.\r\n\r\n**Describe alternatives you've considered**\r\nN.A.\r\n\r\n**Additional context**\r\nRequested by @Geeks-Sid for SBU-TIL.\r\n\n", "before_files": [{"content": "from .crop_zero_planes import CropExternalZeroplanes\nfrom .non_zero_normalize import NonZeroNormalizeOnMaskedRegion\nfrom .threshold_and_clip import (\n    threshold_transform,\n    clip_transform,\n)\nfrom .normalize_rgb import (\n    normalize_by_val_transform,\n    normalize_imagenet_transform,\n    normalize_standardize_transform,\n    normalize_div_by_255_transform,\n)\n\nfrom torchio.transforms import (\n    ZNormalization,\n    ToCanonical,\n)\n\n\ndef positive_voxel_mask(image):\n    return image > 0\n\n\ndef nonzero_voxel_mask(image):\n    return image != 0\n\n\ndef to_canonical_transform(parameters):\n    return ToCanonical()\n\n\n# defining dict for pre-processing - key is the string and the value is the transform object\nglobal_preprocessing_dict = {\n    \"to_canonical\": to_canonical_transform,\n    \"threshold\": threshold_transform,\n    \"clip\": clip_transform,\n    \"clamp\": clip_transform,\n    \"crop_external_zero_planes\": CropExternalZeroplanes,\n    \"normalize_by_val\": normalize_by_val_transform,\n    \"normalize_imagenet\": normalize_imagenet_transform,\n    \"normalize_standardize\": normalize_standardize_transform,\n    \"normalize_div_by_255\": normalize_div_by_255_transform,\n    \"normalize\": ZNormalization(),\n    \"normalize_positive\": ZNormalization(masking_method=positive_voxel_mask),\n    \"normalize_nonZero\": ZNormalization(masking_method=nonzero_voxel_mask),\n    \"normalize_nonZero_masked\": NonZeroNormalizeOnMaskedRegion(),\n}\n", "path": "GANDLF/data/preprocessing/__init__.py"}], "after_files": [{"content": "from .crop_zero_planes import CropExternalZeroplanes\nfrom .non_zero_normalize import NonZeroNormalizeOnMaskedRegion\nfrom .threshold_and_clip import (\n    threshold_transform,\n    clip_transform,\n)\nfrom .normalize_rgb import (\n    normalize_by_val_transform,\n    normalize_imagenet_transform,\n    normalize_standardize_transform,\n    normalize_div_by_255_transform,\n)\n\nfrom torchio.transforms import (\n    ZNormalization,\n    ToCanonical,\n    Crop,\n    CropOrPad,\n)\n\n\ndef positive_voxel_mask(image):\n    return image > 0\n\n\ndef nonzero_voxel_mask(image):\n    return image != 0\n\n\ndef to_canonical_transform(parameters):\n    return ToCanonical()\n\n\ndef crop_transform(patch_size):\n    return Crop(patch_size)\n\n\ndef centercrop_transform(patch_size):\n    return CropOrPad(target_shape=patch_size)\n\n\n# defining dict for pre-processing - key is the string and the value is the transform object\nglobal_preprocessing_dict = {\n    \"to_canonical\": to_canonical_transform,\n    \"threshold\": threshold_transform,\n    \"clip\": clip_transform,\n    \"clamp\": clip_transform,\n    \"crop_external_zero_planes\": CropExternalZeroplanes,\n    \"crop\": crop_transform,\n    \"centercrop\": centercrop_transform,\n    \"normalize_by_val\": normalize_by_val_transform,\n    \"normalize_imagenet\": normalize_imagenet_transform,\n    \"normalize_standardize\": normalize_standardize_transform,\n    \"normalize_div_by_255\": normalize_div_by_255_transform,\n    \"normalize\": ZNormalization(),\n    \"normalize_positive\": ZNormalization(masking_method=positive_voxel_mask),\n    \"normalize_nonZero\": ZNormalization(masking_method=nonzero_voxel_mask),\n    \"normalize_nonZero_masked\": NonZeroNormalizeOnMaskedRegion(),\n}\n", "path": "GANDLF/data/preprocessing/__init__.py"}]}