Git Product home page Git Product logo

counterfactualms's Introduction

SCM for MR images of MS

This repository holds code to generate counterfactual images of MR brain images for people with (and without) MS using a structural causal model (SCM) [1] built in Pyro.

This code was used to generate the counterfactual images in our paper "A Structural Causal Model of MR Images of Multiple Sclerosis".

Our work builds on the work of Pawlowski, Castro, and Glocker [2]. The code in this repository is a fork of their code which can be found here.

The code for the segmentation experiment in our paper can be found here; it depends on msseg. The exact hyperparameters and information about the data used for the segmentation experiment are in the docstring of that script.

This package was developed by Jacob Reinhold of the Image Analysis and Communication Lab (IACL).

Installation

From inside this directory, run:

python setup.py install

or (if you'd like to make updates to the package)

python setup.py develop

Structure

This repository contains code and assets structured as follows:

  • counterfactualms/: contains the code used for running the experiments
    • arch/: model architectures used in experiments
    • datasets/: script for dataset generation and data loading used in experiments
    • distributions/: implementations of useful distributions or transformations
    • experiments/: implementation of experiments
  • assets/: contains hyperparameters for the experiments listed in the paper

References

  1. Pearl, Judea. Causality. Cambridge university press, 2009.
  2. Pawlowski, Nick, Daniel Coelho de Castro, and Ben Glocker. "Deep Structural Causal Models for Tractable Counterfactual Inference." Advances in Neural Information Processing Systems 33 (2020).

counterfactualms's People

Contributors

jcreinhold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

counterfactualms's Issues

Refactor for easier experimentation

The current state of the code is bad. It's hard to understand and essentially hard-coded for the experiments I ran for the paper. But the core functionality could be broken out into class/module which could be extended for other experiments and other types of data.

FileNotFoundError: [Errno 2] No such file or directory: '/iacl/pg20/jacobr/calabresi/png/csv/train_png.csv'

when trying to reproduce the code I was getting this error. I tried to search the '/iacl/pg20/jacobr/calabresi/png/csv/train_png.csv' folder but unable to find It in the repository

GPU available: False, used: False
2023-02-24 11:07:00,828 - lightning - INFO - GPU available: False, used: False
TPU available: None, using: 0 TPU cores
2023-02-24 11:07:00,828 - lightning - INFO - TPU available: None, using: 0 TPU cores
Traceback (most recent call last):
  File "/content/counterfactualms/experiments/classifier/trainer.py", line 83, in <module>
    sys.exit(main())
  File "/content/counterfactualms/experiments/classifier/trainer.py", line 74, in main
    experiment = ClassifierExperiment(hparams)
  File "/usr/local/lib/python3.8/dist-packages/counterfactualms-0.0.1-py3.8.egg/counterfactualms/experiments/classifier/classifier_experiment.py", line 45, in __init__
    self.calabresi_train = CalabresiDataset(self.hparams.train_csv, crop_size=crop_size, crop_type=train_crop_type, resize=resize)  # noqa: E501
  File "/usr/local/lib/python3.8/dist-packages/counterfactualms-0.0.1-py3.8.egg/counterfactualms/datasets/calabresi.py", line 13, in __init__
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/parsers.py", line 605, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/parsers.py", line 457, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/parsers.py", line 814, in __init__
    self._engine = self._make_engine(self.engine)
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/parsers.py", line 1045, in _make_engine
    return mapping[engine](self.f, **self.options)  # type: ignore[call-arg]
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/parsers.py", line 1862, in __init__
    self._open_handles(src, kwds)
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/parsers.py", line 1357, in _open_handles
    self.handles = get_handle(
  File "/usr/local/lib/python3.8/dist-packages/pandas/io/common.py", line 639, in get_handle
    handle = open(
FileNotFoundError: [Errno 2] No such file or directory: '/iacl/pg20/jacobr/calabresi/png/csv/train_png.csv'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.