Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ We define aliases for these meta-transforms under `cc.ctx`:
options:
heading_level: 3

??? quote "<code>[cc.ctx.exclude](cts/#cornucopia.ctx.exclude) is [cc.RandomizedTransform](special/#cornucopia.special.RandomizedTransform)</code>"
??? quote "<code>[cc.ctx.exclude](cts/#cornucopia.ctx.exclude) is [cc.ExcludeKeysTransform](special/#cornucopia.special.RandomizedTransform)</code>"
::: cornucopia.ctx.exclude
options:
heading_level: 3

??? quote "<code>[cc.ctx.consume](cts/#cornucopia.ctx.consume) is [cc.ExcludeKeysTransform](special/#cornucopia.special.ExcludeKeysTransform)</code>"
??? quote "<code>[cc.ctx.consume](cts/#cornucopia.ctx.consume) is [cc.ConsumeKeysTransform](special/#cornucopia.special.ExcludeKeysTransform)</code>"
::: cornucopia.ctx.consume
options:
heading_level: 3
Expand Down Expand Up @@ -641,6 +641,6 @@ We define aliases for these meta-transforms under `cc.ctx`:
heading_level: 3

??? quote "<code>[cc.SynthFromLabelTransform](intensity/#cornucopia.synth.SynthFromLabelTransform)(...)</code> <br/>Synthesize an MRI from an existing label map."
::: cornucopia.synth.IntensityTransform
::: cornucopia.synth.SynthFromLabelTransform
options:
heading_level: 3
24 changes: 14 additions & 10 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,25 +240,28 @@ This is done using the `cc.MappedTransform` meta-transform (or the
`cc.ctx.map` utility function):

```python
# using positionals
geom = cc.RandomElasticTransform()
noise = cc.GaussianNoiseTransform()
trf = cc.SequentialTranform([geom, cc.map(noise, None)])

# using positionals
trf = cc.SequentialTranform([
geom, # apply `geom` to all tensors
cc.ctx.map(noise, None) # apply `noise` to the first tensor only
])
img, lab = trf(img, lab)

# using keywords
geom = cc.RandomElasticTransform()
noise = cc.GaussianNoiseTransform()
trf = cc.SequentialTranform([geom, cc.map(image=noise)])
trf = cc.SequentialTranform([
geom, # apply `geom` to all tensors
cc.ctx.map(image=noise) # apply `noise` to the `image` key.
])
img, lab = trf(image=img, label=lab)

# using dictionaries
dat = [dict(image=img1, label=lab1), dict(image=img2, label=lab2)]
geom = cc.RandomElasticTransform()
noise = cc.GaussianNoiseTransform()
trf = cc.SequentialTranform([
geom,
cc.map(image=noise, nested=True) # !! must be `nested`
cc.ctx.map(image=noise, nested=True) # !! must be `nested`
])
dat = trf(dat)
```
Expand All @@ -269,11 +272,12 @@ Alternatively, a transform can be applied selectively to a set of keys
```python
geom = cc.RandomElasticTransform()
noise = cc.GaussianNoiseTransform()

# Only apply `noise` to the `image` key
trf = cc.SequentialTranform([geom, cc.ctx.include(noise, "image")])
img, lab = trf(image=img, label=lab)

geom = cc.RandomElasticTransform()
noise = cc.GaussianNoiseTransform()
# Apply `noise` to all tensors _except_ the `label` key.
trf = cc.SequentialTranform([geom, cc.ctx.exclude(noise, "label")])
img, lab = trf(image=img, label=lab)
```
Expand Down
Loading