@@ -37,14 +37,18 @@ def _ds_to_dlc_style_df(
3737    pandas.DataFrame 
3838
3939    """ 
40-     # Concatenate the pose tracks and confidence scores into one array 
41-     tracks_with_scores  =  np .concatenate (
42-         (
43-             ds .position .data ,
44-             ds .confidence .data [:, np .newaxis , ...],
45-         ),
46-         axis = 1 ,
47-     )
40+     is_3d  =  "z"  in  columns .get_level_values ("coords" )
41+     if  is_3d :
42+         tracks_with_scores  =  ds .position .data 
43+     else :
44+         # Concatenate the pose tracks and confidence scores into one array 
45+         tracks_with_scores  =  np .concatenate (
46+             (
47+                 ds .position .data ,
48+                 ds .confidence .data [:, np .newaxis , ...],
49+             ),
50+             axis = 1 ,
51+         )
4852    # Reverse the order of the dimensions except for the time dimension 
4953    transpose_order  =  [0 ] +  list (range (tracks_with_scores .ndim  -  1 , 0 , - 1 ))
5054    tracks_with_scores  =  tracks_with_scores .transpose (transpose_order )
@@ -121,7 +125,12 @@ def to_dlc_style_df(
121125    _validate_dataset (ds , ValidPosesDataset )
122126    scorer  =  ["movement" ]
123127    bodyparts  =  ds .coords ["keypoints" ].data .tolist ()
124-     coords  =  ds .coords ["space" ].data .tolist () +  ["likelihood" ]
128+     base_coords  =  ds .coords ["space" ].data .tolist ()
129+     coords  =  (
130+         base_coords 
131+         if  "z"  in  ds .coords ["space" ]
132+         else  base_coords  +  ["likelihood" ]
133+     )
125134    individuals  =  ds .coords ["individuals" ].data .tolist ()
126135
127136    if  split_individuals :
0 commit comments