@@ -142,38 +142,6 @@ def __call__(self, data: Any) -> Any:
142142 return data
143143
144144
145- @deprecated (since = "0.8" , msg_suffix = "please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead." )
146- class AsChannelFirst (Transform ):
147- """
148- Change the channel dimension of the image to the first dimension.
149-
150- Most of the image transformations in ``monai.transforms``
151- assume the input image is in the channel-first format, which has the shape
152- (num_channels, spatial_dim_1[, spatial_dim_2, ...]).
153-
154- This transform could be used to convert, for example, a channel-last image array in shape
155- (spatial_dim_1[, spatial_dim_2, ...], num_channels) into the channel-first format,
156- so that the multidimensional image array can be correctly interpreted by the other transforms.
157-
158- Args:
159- channel_dim: which dimension of input image is the channel, default is the last dimension.
160- """
161-
162- backend = [TransformBackends .TORCH , TransformBackends .NUMPY ]
163-
164- def __init__ (self , channel_dim : int = - 1 ) -> None :
165- if not (isinstance (channel_dim , int ) and channel_dim >= - 1 ):
166- raise ValueError (f"invalid channel dimension ({ channel_dim } )." )
167- self .channel_dim = channel_dim
168-
169- def __call__ (self , img : NdarrayOrTensor ) -> NdarrayOrTensor :
170- """
171- Apply the transform to `img`.
172- """
173- out : NdarrayOrTensor = convert_to_tensor (moveaxis (img , self .channel_dim , 0 ), track_meta = get_track_meta ())
174- return out
175-
176-
177145class AsChannelLast (Transform ):
178146 """
179147 Change the channel dimension of the image to the last dimension.
@@ -204,31 +172,6 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor:
204172 return out
205173
206174
207- @deprecated (since = "0.8" , msg_suffix = "please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead." )
208- class AddChannel (Transform ):
209- """
210- Adds a 1-length channel dimension to the input image.
211-
212- Most of the image transformations in ``monai.transforms``
213- assumes the input image is in the channel-first format, which has the shape
214- (num_channels, spatial_dim_1[, spatial_dim_2, ...]).
215-
216- This transform could be used, for example, to convert a (spatial_dim_1[, spatial_dim_2, ...])
217- spatial image into the channel-first format so that the
218- multidimensional image array can be correctly interpreted by the other
219- transforms.
220- """
221-
222- backend = [TransformBackends .TORCH , TransformBackends .NUMPY ]
223-
224- def __call__ (self , img : NdarrayOrTensor ) -> NdarrayOrTensor :
225- """
226- Apply the transform to `img`.
227- """
228- out : NdarrayOrTensor = convert_to_tensor (img [None ], track_meta = get_track_meta ())
229- return out
230-
231-
232175class EnsureChannelFirst (Transform ):
233176 """
234177 Adjust or add the channel dimension of input data to ensure `channel_first` shape.
@@ -291,6 +234,54 @@ def __call__(self, img: torch.Tensor, meta_dict: Mapping | None = None) -> torch
291234 return convert_to_tensor (result , track_meta = get_track_meta ()) # type: ignore
292235
293236
237+ @deprecated (
238+ since = "0.8" ,
239+ removed = "1.3" ,
240+ msg_suffix = "please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead." ,
241+ )
242+ class AsChannelFirst (EnsureChannelFirst ):
243+ """
244+ Change the channel dimension of the image to the first dimension.
245+ Most of the image transformations in ``monai.transforms``
246+ assume the input image is in the channel-first format, which has the shape
247+ (num_channels, spatial_dim_1[, spatial_dim_2, ...]).
248+ This transform could be used to convert, for example, a channel-last image array in shape
249+ (spatial_dim_1[, spatial_dim_2, ...], num_channels) into the channel-first format,
250+ so that the multidimensional image array can be correctly interpreted by the other transforms.
251+ Args:
252+ channel_dim: which dimension of input image is the channel, default is the last dimension.
253+ """
254+
255+ def __init__ (self , channel_dim : int = - 1 ) -> None :
256+ super ().__init__ (channel_dim = channel_dim )
257+
258+
259+ @deprecated (
260+ since = "0.8" ,
261+ removed = "1.3" ,
262+ msg_suffix = "please use MetaTensor data type and monai.transforms.EnsureChannelFirst instead"
263+ " with `channel_dim='no_channel'`." ,
264+ )
265+ class AddChannel (EnsureChannelFirst ):
266+ """
267+ Adds a 1-length channel dimension to the input image.
268+
269+ Most of the image transformations in ``monai.transforms``
270+ assumes the input image is in the channel-first format, which has the shape
271+ (num_channels, spatial_dim_1[, spatial_dim_2, ...]).
272+
273+ This transform could be used, for example, to convert a (spatial_dim_1[, spatial_dim_2, ...])
274+ spatial image into the channel-first format so that the
275+ multidimensional image array can be correctly interpreted by the other
276+ transforms.
277+ """
278+
279+ backend = [TransformBackends .TORCH , TransformBackends .NUMPY ]
280+
281+ def __init__ (self ) -> None :
282+ super ().__init__ (channel_dim = "no_channel" )
283+
284+
294285class RepeatChannel (Transform ):
295286 """
296287 Repeat channel data to construct expected input shape for models.
@@ -391,7 +382,7 @@ def __call__(self, img: torch.Tensor) -> list[torch.Tensor]:
391382 return outputs
392383
393384
394- @deprecated (since = "0.8" , msg_suffix = "please use `SplitDim` instead." )
385+ @deprecated (since = "0.8" , removed = "1.3" , msg_suffix = "please use `SplitDim` instead." )
395386class SplitChannel (SplitDim ):
396387 """
397388 Split Numpy array or PyTorch Tensor data according to the channel dim.
0 commit comments