Skip to content

Commit 220dbda

Browse files
authored
[DOC] fixes (#48)
* [DOC] fix (cc.map -> cc.ctx.map) + improve readability of some examples * [DOC] fix a couple of wrong references in api index
1 parent 5f6681c commit 220dbda

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

docs/api/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ We define aliases for these meta-transforms under `cc.ctx`:
8888
options:
8989
heading_level: 3
9090

91-
??? quote "<code>[cc.ctx.exclude](cts/#cornucopia.ctx.exclude) is [cc.RandomizedTransform](special/#cornucopia.special.RandomizedTransform)</code>"
91+
??? quote "<code>[cc.ctx.exclude](cts/#cornucopia.ctx.exclude) is [cc.ExcludeKeysTransform](special/#cornucopia.special.RandomizedTransform)</code>"
9292
::: cornucopia.ctx.exclude
9393
options:
9494
heading_level: 3
9595

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

643643
??? quote "<code>[cc.SynthFromLabelTransform](intensity/#cornucopia.synth.SynthFromLabelTransform)(...)</code> <br/>Synthesize an MRI from an existing label map."
644-
::: cornucopia.synth.IntensityTransform
644+
::: cornucopia.synth.SynthFromLabelTransform
645645
options:
646646
heading_level: 3

docs/start.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,25 +240,28 @@ This is done using the `cc.MappedTransform` meta-transform (or the
240240
`cc.ctx.map` utility function):
241241

242242
```python
243-
# using positionals
244243
geom = cc.RandomElasticTransform()
245244
noise = cc.GaussianNoiseTransform()
246-
trf = cc.SequentialTranform([geom, cc.map(noise, None)])
245+
246+
# using positionals
247+
trf = cc.SequentialTranform([
248+
geom, # apply `geom` to all tensors
249+
cc.ctx.map(noise, None) # apply `noise` to the first tensor only
250+
])
247251
img, lab = trf(img, lab)
248252

249253
# using keywords
250-
geom = cc.RandomElasticTransform()
251-
noise = cc.GaussianNoiseTransform()
252-
trf = cc.SequentialTranform([geom, cc.map(image=noise)])
254+
trf = cc.SequentialTranform([
255+
geom, # apply `geom` to all tensors
256+
cc.ctx.map(image=noise) # apply `noise` to the `image` key.
257+
])
253258
img, lab = trf(image=img, label=lab)
254259

255260
# using dictionaries
256261
dat = [dict(image=img1, label=lab1), dict(image=img2, label=lab2)]
257-
geom = cc.RandomElasticTransform()
258-
noise = cc.GaussianNoiseTransform()
259262
trf = cc.SequentialTranform([
260263
geom,
261-
cc.map(image=noise, nested=True) # !! must be `nested`
264+
cc.ctx.map(image=noise, nested=True) # !! must be `nested`
262265
])
263266
dat = trf(dat)
264267
```
@@ -269,11 +272,12 @@ Alternatively, a transform can be applied selectively to a set of keys
269272
```python
270273
geom = cc.RandomElasticTransform()
271274
noise = cc.GaussianNoiseTransform()
275+
276+
# Only apply `noise` to the `image` key
272277
trf = cc.SequentialTranform([geom, cc.ctx.include(noise, "image")])
273278
img, lab = trf(image=img, label=lab)
274279

275-
geom = cc.RandomElasticTransform()
276-
noise = cc.GaussianNoiseTransform()
280+
# Apply `noise` to all tensors _except_ the `label` key.
277281
trf = cc.SequentialTranform([geom, cc.ctx.exclude(noise, "label")])
278282
img, lab = trf(image=img, label=lab)
279283
```

0 commit comments

Comments
 (0)