niftynet.contrib.csv_reader.csv_reader module

class CSVReader(names=None)[source]

Bases: niftynet.layer.base_layer.Layer

Class that performs the reading of the csv_input and select the lines according to the subject id if available

initialise(data_param, task_param=None, file_list=None, sample_per_volume=1)[source]

this function takes in a data_param specifying the name of the source and the location of the csv data. Three input modes are supported: - ‘label’ - expects a csv with header subject_id,label. - ‘features’ - expects a csv with header subject_id,<name of feature 1>,<name of feature 2> e.g.:

data_param = {'label': {'csv_data_file': 'path/to/some_data.csv', 'to_ohe': False}}
Parameters:
  • data_param – dictionary of input sections
  • task_param – Namespace object
  • file_list – a dataframe generated by ImagePartitioner
  • sample_per_volume – number of samples taken per volume (useful
to know how much to tile the csv output
for cross validation, so that the reader only loads files in training/inference phases.
static to_ohe(labels, _dims)[source]

Transform the labeling to one hot encoding :param labels: labels to encode :param _dims: :return:

static to_categorical(labels, label_names)[source]

Transformation of labels to categorical :param labels: labels to change :param label_names: :return:

layer_op(idx=None, subject_id=None, mode='single', reject=True)[source]

Perform the csv_reading and assignment to dictionary :param idx: index of the image :param subject_id: subject id :param mode: chosen mode (multi or single) :param reject: if some elements should be rejected :return:

tile_nsamples(data)[source]

Tile the csv_read to have the same value applied to the nsamples extracted from the volume :param data: csv data to tile for all samples extracted in the volume :return: tiled data

shapes

dict of label shape and label location shape

Type:return
tf_dtypes

Infer input data dtypes in TF

tf_shapes

a dictionary of sampler output tensor shapes

Type:return
static apply_niftynet_format_to_data(data)[source]
<<<<<<< HEAD
Transform the dtaa to be of dimension 5d
Transform the data to be of dimension 5d
>>>>>>> 7a0386e78f01c88b707e08f759f910abba9b71b1
param data:data to expand
return:expanded data