Skip to content

Feature: Next-Gen CAREamist API#717

Merged
jdeschamps merged 21 commits into
mainfrom
mc/feat/careamist-v2
Feb 4, 2026
Merged

Feature: Next-Gen CAREamist API#717
jdeschamps merged 21 commits into
mainfrom
mc/feat/careamist-v2

Conversation

@melisande-c
Copy link
Copy Markdown
Member

Description

Note

tldr: Skeleton of new version of the CAREamist API that uses the Next-Gen Dataset and refactored Lightning Modules. Only initialising from a config/config file or a checkpoint has been implemented.

Background - why do we need this PR?

With everything that has changed with the recent refactoring it is easier to rewrite the CAREamics API rather than try and integrate the changes.

Overview - what changed?

  • If loading from a checkpoint or bmz, the training_config and experiment_name can be overridden.
    • The plan is to pass the checkpoint path to the trainer which will load the optimiser and LR schedular state dicts, this means however that if someone wants to resume training, they will likely have to increase the max epochs.
    • If finetuning one might want to override the experiment name.
  • HyperParametersCallback replaced by calls to save_hyperparameters in the lightning modules and data_modules plus a new CareamicsCheckpointInfo callback.
    • Lighning module save the algorithm config, data module saves the data config, and CareamicsCheckpointInfo saves the training_config, the experiment_name and the version.
    • Should be more convenient for Lightning API users (they don't need to remember HyperParametersCallback.
    • checkpoints saved without CareamicsCheckpointInfo can still be loaded by the CAREamist API if a training_config and experiment_name are provided at initialisation.

Implementation - how did you implement the changes?

Copied most of the function signatures from original CAREamist API.

Decided to use overloads for different initialisation paths, we could also discuss @classmethod constructors.

Changes Made

New features or files

  • CAREamistV2
  • CareamicsCheckpointInfo
  • helper functions for lightning module creation in src/careamics/lightning/dataset_ng/lightning_modules/get_module.py

How has this been tested?

No tests yet

Related Issues


Please ensure your PR meets the following requirements:

  • Code builds and passes tests locally, including doctests
  • New tests have been added (for bug fixes/features)
  • Pre-commit passes
  • PR to the documentation exists (for bug fixes / features)

Comment thread src/careamics/careamist_v2.py Outdated
Comment thread src/careamics/careamist_v2.py
Comment thread src/careamics/careamist_v2.py Outdated
Comment thread src/careamics/careamist_v2.py Outdated
)

@staticmethod
def _from_config(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should prob discuss using 3 separate methods, CAREamist.from_config, from_checkpoint etc

@jdeschamps
Copy link
Copy Markdown
Member

Just pointing out also that there is an import error in the tests!

@melisande-c
Copy link
Copy Markdown
Member Author

Just pointing out also that there is an import error in the tests!

Looks like this might be due to rebase artefact after inheritance of UNetModule was removed from lightning module, I will have a look at that

@melisande-c
Copy link
Copy Markdown
Member Author

There is a new error with the tests, I will have a look tomorrow morning

@veegalinova veegalinova marked this pull request as ready for review February 4, 2026 12:21
@veegalinova veegalinova requested a review from a team February 4, 2026 12:21
@jdeschamps jdeschamps merged commit 8cb3ba2 into main Feb 4, 2026
13 checks passed
@jdeschamps jdeschamps deleted the mc/feat/careamist-v2 branch February 4, 2026 13:27
melisande-c added a commit that referenced this pull request Feb 4, 2026
## Description

> [!NOTE]  
> **tldr**: Skeleton of new version of the CAREamist API that uses the
Next-Gen Dataset and refactored Lightning Modules. Only initialising
from a config/config file or a checkpoint has been implemented.


### Background - why do we need this PR?

With everything that has changed with the recent refactoring it is
easier to rewrite the CAREamics API rather than try and integrate the
changes.

### Overview - what changed?

- If loading from a checkpoint or bmz, the `training_config` and
`experiment_name` can be overridden.
- The plan is to pass the checkpoint path to the trainer which will load
the optimiser and LR schedular state dicts, this means however that if
someone wants to resume training, they will likely have to increase the
max epochs.
  - If finetuning one might want to override the experiment name.
- `HyperParametersCallback` replaced by calls to `save_hyperparameters`
in the lightning modules and data_modules plus a new
`CareamicsCheckpointInfo` callback.
- Lighning module save the algorithm config, data module saves the data
config, and `CareamicsCheckpointInfo` saves the training_config, the
experiment_name and the version.
- Should be more convenient for Lightning API users (they don't need to
remember `HyperParametersCallback`.
- checkpoints saved without `CareamicsCheckpointInfo` can still be
loaded by the CAREamist API if a `training_config` and `experiment_name`
are provided at initialisation.

### Implementation - how did you implement the changes?

Copied most of the function signatures from original CAREamist API.

Decided to use overloads for different initialisation paths, we could
also discuss `@classmethod` constructors.

## Changes Made

### New features or files

- CAREamistV2
- `CareamicsCheckpointInfo`
- helper functions for lightning module creation in
`src/careamics/lightning/dataset_ng/lightning_modules/get_module.py`

## How has this been tested?

No tests yet


## Related Issues

- Resolves #649 

---

**Please ensure your PR meets the following requirements:**

- [ ] Code builds and passes tests locally, including doctests
- [ ] New tests have been added (for bug fixes/features)
- [ ] Pre-commit passes
- [ ] PR to the documentation exists (for bug fixes / features)

---------

Co-authored-by: veegalinova <[email protected]>
Co-authored-by: Vera Galinova <[email protected]>
Co-authored-by: Joran Deschamps <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Next-Gen Dataset: base for CAREamist-like module as high-level API

4 participants