Title: Errors in final cells: NameError for tpointsI and AttributeError for .to_csv()
Description
In the last two cells of the tutorial, there are two errors:
- NameError:
name 'tpointsI' is not defined
- The code uses
tpointsI.numpy() in np.hstack((df, tpointsI.numpy())), but tpointsI is never defined. It looks like the intended variable might be tpointsJ instead, or another point transformation variable.
- AttributeError:
'numpy.ndarray' object has no attribute 'to_csv'
- After using
np.hstack, the result is a NumPy array, which doesn’t have a .to_csv() method. Converting to a pandas DataFrame before calling .to_csv() would fix this.
These issues occur in docs/notebooks/xenium-heimage-alignment.ipynb.
Proposed Fixes
- Replace
tpointsI with the correct variable (likely tpointsJ).
- Instead of using
np.hstack, add the aligned coordinates directly to the original DataFrame and then export it. For example:
# Create a copy of the original DataFrame
df_results = df.copy()
# Add aligned coordinates to the DataFrame
df_results['aligned_y'] = tpointsJ[:, 0].detach().numpy()
df_results['aligned_x'] = tpointsJ[:, 1].detach().numpy()
# Save the new DataFrame as a compressed CSV
df_results.to_csv(
'../xenium_data/Xenium_Breast_Cancer_Rep1_STalign_to_HE.csv.gz',
compression='gzip',
index=False
)