diff --git a/docs/api/index.md b/docs/api/index.md index b6ff786..7e406dd 100755 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -88,12 +88,12 @@ We define aliases for these meta-transforms under `cc.ctx`: options: heading_level: 3 -??? quote "[cc.ctx.exclude](cts/#cornucopia.ctx.exclude) is [cc.RandomizedTransform](special/#cornucopia.special.RandomizedTransform)" +??? quote "[cc.ctx.exclude](cts/#cornucopia.ctx.exclude) is [cc.ExcludeKeysTransform](special/#cornucopia.special.RandomizedTransform)" ::: cornucopia.ctx.exclude options: heading_level: 3 -??? quote "[cc.ctx.consume](cts/#cornucopia.ctx.consume) is [cc.ExcludeKeysTransform](special/#cornucopia.special.ExcludeKeysTransform)" +??? quote "[cc.ctx.consume](cts/#cornucopia.ctx.consume) is [cc.ConsumeKeysTransform](special/#cornucopia.special.ExcludeKeysTransform)" ::: cornucopia.ctx.consume options: heading_level: 3 @@ -641,6 +641,6 @@ We define aliases for these meta-transforms under `cc.ctx`: heading_level: 3 ??? quote "[cc.SynthFromLabelTransform](intensity/#cornucopia.synth.SynthFromLabelTransform)(...)
Synthesize an MRI from an existing label map." - ::: cornucopia.synth.IntensityTransform + ::: cornucopia.synth.SynthFromLabelTransform options: heading_level: 3 diff --git a/docs/start.md b/docs/start.md index 637c43b..a8d045f 100755 --- a/docs/start.md +++ b/docs/start.md @@ -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) ``` @@ -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) ```