Package io.github.hakkelt.bartwrapper
Class Bart
- java.lang.Object
-
- io.github.hakkelt.bartwrapper.Bart
-
public class Bart extends Object
Driver for BART
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
execute(Object... args)
Execute a BART command Example:static void
execute(Consumer<String> outputConsumer, Object... args)
Execute a BART command Example:static String
read(Object... args)
Executes a BART command and reads its output to a String Example:static BartNDArray
run(Object... args)
Executes a BART command and reads its output to an NDArraystatic BartNDArray
run(Consumer<String> outputConsumer, Object... args)
Executes a BART command and reads its output to an NDArray.
-
-
-
Method Detail
-
execute
public static void execute(Object... args) throws BartException
Execute a BART command- Example:
BartNDArray input = new BartFloatNDArray(128, 128).fill(new Complex(1,-1)); File output = File.createTempFile("bart_", ".ra"); Bart.execute("cabs", input, output); BartNDArray result = BartNDArray.load(output));
- Parameters:
args
- name of BART command and its arguments- Throws:
BartException
- when running BART fails for any reason
-
execute
public static void execute(Consumer<String> outputConsumer, Object... args) throws BartException
Execute a BART command- Example:
BartNDArray input = new BartFloatNDArray(128, 128).fill(new Complex(1,-1)); File output = File.createTempFile("bart_", ".ra"); StringBuilder str = new StringBuilder(); Bart.execute(outputLine -> str.append(outputLine).append(System.lineSeparator()), "cabs", input, output); BartNDArray result = BartNDArray.load(output)); System.out.println(str.toString());
- Parameters:
outputConsumer
- a function that accepts a String as input. This function will receive the output of the BART command line by line.args
- name of BART command and its arguments- Throws:
BartException
- when running BART fails for any reason
-
read
public static String read(Object... args) throws BartException
Executes a BART command and reads its output to a String- Example:
String result = Bart.read("bitmask", "-b", 7);
- Parameters:
args
- name of BART command and its arguments- Returns:
- result of the BART command
- Throws:
BartException
- when running BART fails for any reason
-
run
public static BartNDArray run(Object... args) throws BartException
Executes a BART command and reads its output to an NDArrayNote: It is assumed that the BART command to be executed saves its output to a file and it expects the name of the file to be specified as the last argument. When passing arguments to this function, this last argument specifying the output file name should be omitted as it is handled automaticall by this driver.
- Example:
BartNDArray array = new BartFloatNDArray(128, 128).fill(new Complex(1,-1)); BartNDArray bartAbs = Bart.run("cabs", array).squeeze();
- Parameters:
args
- name of BART command and its arguments- Returns:
- NDArray that holds the output of the BART command
- Throws:
BartException
- when running Bart fails for any reason
-
run
public static BartNDArray run(Consumer<String> outputConsumer, Object... args) throws BartException
Executes a BART command and reads its output to an NDArray.Note: It is assumed that the BART command to be executed saves its output to a file and it expects the name of the file to be specified as the last argument. When passing arguments to this function, this last argument specifying the output file name should be omitted as it is handled automaticall by this driver.
- Example:
BartNDArray array = new BartFloatNDArray(128, 128).fill(new Complex(1,-1)); StringBuilder str = new StringBuilder(); BartNDArray bartAbs = Bart.run(outputLine -> str.append(outputLine).append(System.lineSeparator()), "cabs", array).squeeze(); System.out.println(str.toString());
- Parameters:
outputConsumer
- a function that accepts a String as input. This function will receive the output of the BART command line by line.args
- name of BART command and its arguments- Returns:
- NDArray that holds the output of the BART command
- Throws:
BartException
- when running Bart fails for any reason
-
-