repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
holmari/gerritstats | GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/ProjectLister.java | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
| import com.holmsted.gerrit.GerritServer;
import java.util.List;
import javax.annotation.Nonnull; | package com.holmsted.gerrit.downloaders;
public abstract class ProjectLister {
@Nonnull | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
// Path: GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/ProjectLister.java
import com.holmsted.gerrit.GerritServer;
import java.util.List;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.downloaders;
public abstract class ProjectLister {
@Nonnull | private final GerritServer gerritServer; |
holmari/gerritstats | GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/ssh/GerritSshCommand.java | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
| import com.holmsted.gerrit.GerritServer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.annotation.Nonnull; | package com.holmsted.gerrit.downloaders.ssh;
public class GerritSshCommand {
@Nonnull | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
// Path: GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/ssh/GerritSshCommand.java
import com.holmsted.gerrit.GerritServer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.downloaders.ssh;
public class GerritSshCommand {
@Nonnull | private final GerritServer gerritServer; |
holmari/gerritstats | GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/AbstractGerritStatsDownloader.java | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
| import javax.annotation.Nonnull;
import com.holmsted.gerrit.GerritServer;
import org.json.JSONObject;
import java.util.List; | package com.holmsted.gerrit.downloaders;
public abstract class AbstractGerritStatsDownloader {
public static final int NO_COMMIT_LIMIT = -1;
@Nonnull | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
// Path: GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/AbstractGerritStatsDownloader.java
import javax.annotation.Nonnull;
import com.holmsted.gerrit.GerritServer;
import org.json.JSONObject;
import java.util.List;
package com.holmsted.gerrit.downloaders;
public abstract class AbstractGerritStatsDownloader {
public static final int NO_COMMIT_LIMIT = -1;
@Nonnull | private final GerritServer gerritServer; |
holmari/gerritstats | GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/ssh/GerritSsh.java | // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
//
// Path: GerritCommon/src/main/java/com/holmsted/gerrit/GerritVersion.java
// public final class GerritVersion {
// public final int major;
// public final int minor;
// public final int patch;
//
// public static GerritVersion fromString(String versionString) {
// // output format for new Gerrit versions: "gerrit version X.YY.ZZ"
// String[] versionParts = versionString.trim().split("\\.");
// int major = Integer.parseInt(versionParts[0]);
// int minor;
// int patch;
//
// if (versionParts.length >= 3) {
// minor = safeValueOf(versionParts[1]);
// patch = safeValueOf(versionParts[2]);
// } else if (versionParts.length == 2) {
// // Output format for older Gerrit versions: "gerrit version X.YY-ZZ-gitsha"
// String[] dotVersionParts = versionParts[1].split("-");
//
// minor = dotVersionParts.length > 0 ? safeValueOf(dotVersionParts[0]) : -1;
// patch = dotVersionParts.length > 1 ? safeValueOf(dotVersionParts[1]) : -1;
// } else {
// minor = -1;
// patch = -1;
// System.err.println(String.format("Unknown version string '%s'", versionString));
// }
//
// return new GerritVersion(major, minor, patch);
// }
//
// public static GerritVersion makeInvalid() {
// return new GerritVersion(-1, -1, -1);
// }
//
// private GerritVersion(int major, int minor, int patch) {
// this.major = major;
// this.minor = minor;
// this.patch = patch;
// }
//
// private static int safeValueOf(@Nullable String numberAsString) {
// try {
// if (numberAsString != null) {
// return Integer.parseInt(numberAsString);
// } else {
// return -1;
// }
// } catch (NumberFormatException ex) {
// return -1;
// }
// }
//
// // Version 3.1 must pass the "isAtLeast" test against 2.9 even tho 1 < 9.
// public boolean isAtLeast(int expectedMajor, int expectedMinor) {
// return this.major > expectedMajor || (this.major == expectedMajor && this.minor >= expectedMinor);
// }
//
// public boolean isAtLeast(@Nonnull GerritVersion otherVersion) {
// return isAtLeast(otherVersion.major, otherVersion.minor);
// }
//
// public boolean isInvalid() {
// return major == -1 && minor == -1 && patch == -1;
// }
//
// public String toString() {
// return String.format("%d.%d.%d", major, minor, patch);
// }
// }
| import com.holmsted.gerrit.GerritServer;
import com.holmsted.gerrit.GerritVersion;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull; | package com.holmsted.gerrit.downloaders.ssh;
public final class GerritSsh {
public static List<String> listProjects(@Nonnull GerritServer gerritServer) {
GerritSshCommand sshCommand = new GerritSshCommand(gerritServer);
String output = sshCommand.exec("ls-projects");
List<String> projectList = new ArrayList<>();
Collections.addAll(projectList, output.split("\n"));
return projectList;
}
| // Path: GerritDownloader/src/main/java/com/holmsted/gerrit/GerritServer.java
// public class GerritServer {
//
// private static final int GERRIT_DEFAULT_PORT = 29418;
// private final int port;
//
// @Nonnull
// private final String serverName;
// private final String privateKey;
//
// public GerritServer(@Nonnull String serverName, int port, @Nonnull String privateKey) {
// this.serverName = serverName;
// this.port = port != 0 ? port : GERRIT_DEFAULT_PORT;
// this.privateKey = privateKey;
// }
//
// public String getServerName() {
// return serverName;
// }
//
// public int getPort() {
// return port;
// }
//
// public String getPrivateKey() {
// return privateKey;
// }
//
// @Override
// public String toString() {
// return String.format("%s:%d", serverName, port);
// }
// }
//
// Path: GerritCommon/src/main/java/com/holmsted/gerrit/GerritVersion.java
// public final class GerritVersion {
// public final int major;
// public final int minor;
// public final int patch;
//
// public static GerritVersion fromString(String versionString) {
// // output format for new Gerrit versions: "gerrit version X.YY.ZZ"
// String[] versionParts = versionString.trim().split("\\.");
// int major = Integer.parseInt(versionParts[0]);
// int minor;
// int patch;
//
// if (versionParts.length >= 3) {
// minor = safeValueOf(versionParts[1]);
// patch = safeValueOf(versionParts[2]);
// } else if (versionParts.length == 2) {
// // Output format for older Gerrit versions: "gerrit version X.YY-ZZ-gitsha"
// String[] dotVersionParts = versionParts[1].split("-");
//
// minor = dotVersionParts.length > 0 ? safeValueOf(dotVersionParts[0]) : -1;
// patch = dotVersionParts.length > 1 ? safeValueOf(dotVersionParts[1]) : -1;
// } else {
// minor = -1;
// patch = -1;
// System.err.println(String.format("Unknown version string '%s'", versionString));
// }
//
// return new GerritVersion(major, minor, patch);
// }
//
// public static GerritVersion makeInvalid() {
// return new GerritVersion(-1, -1, -1);
// }
//
// private GerritVersion(int major, int minor, int patch) {
// this.major = major;
// this.minor = minor;
// this.patch = patch;
// }
//
// private static int safeValueOf(@Nullable String numberAsString) {
// try {
// if (numberAsString != null) {
// return Integer.parseInt(numberAsString);
// } else {
// return -1;
// }
// } catch (NumberFormatException ex) {
// return -1;
// }
// }
//
// // Version 3.1 must pass the "isAtLeast" test against 2.9 even tho 1 < 9.
// public boolean isAtLeast(int expectedMajor, int expectedMinor) {
// return this.major > expectedMajor || (this.major == expectedMajor && this.minor >= expectedMinor);
// }
//
// public boolean isAtLeast(@Nonnull GerritVersion otherVersion) {
// return isAtLeast(otherVersion.major, otherVersion.minor);
// }
//
// public boolean isInvalid() {
// return major == -1 && minor == -1 && patch == -1;
// }
//
// public String toString() {
// return String.format("%d.%d.%d", major, minor, patch);
// }
// }
// Path: GerritDownloader/src/main/java/com/holmsted/gerrit/downloaders/ssh/GerritSsh.java
import com.holmsted.gerrit.GerritServer;
import com.holmsted.gerrit.GerritVersion;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.downloaders.ssh;
public final class GerritSsh {
public static List<String> listProjects(@Nonnull GerritServer gerritServer) {
GerritSshCommand sshCommand = new GerritSshCommand(gerritServer);
String output = sshCommand.exec("ls-projects");
List<String> projectList = new ArrayList<>();
Collections.addAll(projectList, output.split("\n"));
return projectList;
}
| public static GerritVersion version(@Nonnull GerritServer gerritServer) { |
holmari/gerritstats | GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java | // Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
//
// @Nonnull
// private final List<String> includedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> excludedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> includedBranches = new ArrayList<>();
//
// private boolean includeEmptyEmails;
//
// CommitFilter() {
// }
//
// public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
// this.includedEmails.addAll(excludeEmails);
// }
//
// public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
// this.excludedEmails.addAll(excludeEmails);
// }
//
// public void setIncludeBranches(@Nonnull List<String> includeBranches) {
// this.includedBranches.addAll(includeBranches);
// }
//
// public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
// this.includeEmptyEmails = includeEmptyEmails;
// }
//
// public boolean isIncluded(@Nonnull Commit commit) {
// return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
// }
//
// public boolean isIncluded(@Nullable Commit.Identity identity) {
// if (identity == null || identity.email == null) {
// return includeEmptyEmails;
// } else {
// if (!includedEmails.isEmpty()) {
// return includedEmails.contains(identity.email);
// } else {
// return !excludedEmails.contains(identity.email);
// }
// }
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
//
// public static final int INVALID_PATCH_COUNT = -1;
//
// @Nonnull
// private final CommandLineParser commandLine;
//
// OutputRules(@Nonnull CommandLineParser commandLine) {
// this.commandLine = commandLine;
// }
//
// public String getOutputDir() {
// return commandLine.getOutputDir();
// }
//
// public boolean isAnonymizeDataEnabled() {
// return commandLine.isAnonymizeDataEnabled();
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
// @Nonnull
// private final List<Commit> commits;
// @Nonnull
// private final List<String> filenames;
// @Nonnull
// private final GerritVersion minVersion;
//
// @Nonnull
// private final List<String> branches;
//
// private String datasetKey;
//
// QueryData(@Nonnull List<String> filenames,
// @Nonnull List<Commit> commits,
// @Nonnull GerritVersion minVersion) {
//
// this.filenames = ImmutableList.copyOf(filenames);
// this.commits = ImmutableList.copyOf(commits);
// this.minVersion = minVersion;
// this.branches = this.commits.stream().map(commit -> commit.branch)
// .distinct().collect(Collectors.toList());
// }
//
// public String getDisplayableProjectName() {
// return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
// }
//
// @Nonnull
// public List<String> getFilenames() {
// return this.filenames;
// }
//
// public List<String> getBranches() {
// return this.branches;
// }
//
// @Nonnull
// public List<Commit> getCommits() {
// return commits;
// }
//
// /**
// * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
// * check for whether the data was generated with the same files.
// */
// @Nonnull
// public String getDatasetKey() {
// if (this.datasetKey == null) {
// List<String> filenames = new ArrayList<>(getFilenames());
// Collections.sort(filenames);
// HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
// for (String filename : filenames) {
// hashCodeBuilder.append(filename);
// }
// this.datasetKey = hashCodeBuilder.build().toString();
// }
//
// return this.datasetKey;
// }
//
// @Nonnull
// public QueryData anonymize() {
// CommitAnonymizer anonymizer = new CommitAnonymizer();
// List<Commit> anonymizedCommits = anonymizer.process(commits);
// return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
// }
//
// public GerritVersion getMinGerritVersion() {
// return minVersion;
// }
// }
| import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull; | package com.holmsted.gerrit.processors;
public abstract class CommitDataProcessor<T> {
@Nonnull | // Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
//
// @Nonnull
// private final List<String> includedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> excludedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> includedBranches = new ArrayList<>();
//
// private boolean includeEmptyEmails;
//
// CommitFilter() {
// }
//
// public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
// this.includedEmails.addAll(excludeEmails);
// }
//
// public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
// this.excludedEmails.addAll(excludeEmails);
// }
//
// public void setIncludeBranches(@Nonnull List<String> includeBranches) {
// this.includedBranches.addAll(includeBranches);
// }
//
// public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
// this.includeEmptyEmails = includeEmptyEmails;
// }
//
// public boolean isIncluded(@Nonnull Commit commit) {
// return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
// }
//
// public boolean isIncluded(@Nullable Commit.Identity identity) {
// if (identity == null || identity.email == null) {
// return includeEmptyEmails;
// } else {
// if (!includedEmails.isEmpty()) {
// return includedEmails.contains(identity.email);
// } else {
// return !excludedEmails.contains(identity.email);
// }
// }
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
//
// public static final int INVALID_PATCH_COUNT = -1;
//
// @Nonnull
// private final CommandLineParser commandLine;
//
// OutputRules(@Nonnull CommandLineParser commandLine) {
// this.commandLine = commandLine;
// }
//
// public String getOutputDir() {
// return commandLine.getOutputDir();
// }
//
// public boolean isAnonymizeDataEnabled() {
// return commandLine.isAnonymizeDataEnabled();
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
// @Nonnull
// private final List<Commit> commits;
// @Nonnull
// private final List<String> filenames;
// @Nonnull
// private final GerritVersion minVersion;
//
// @Nonnull
// private final List<String> branches;
//
// private String datasetKey;
//
// QueryData(@Nonnull List<String> filenames,
// @Nonnull List<Commit> commits,
// @Nonnull GerritVersion minVersion) {
//
// this.filenames = ImmutableList.copyOf(filenames);
// this.commits = ImmutableList.copyOf(commits);
// this.minVersion = minVersion;
// this.branches = this.commits.stream().map(commit -> commit.branch)
// .distinct().collect(Collectors.toList());
// }
//
// public String getDisplayableProjectName() {
// return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
// }
//
// @Nonnull
// public List<String> getFilenames() {
// return this.filenames;
// }
//
// public List<String> getBranches() {
// return this.branches;
// }
//
// @Nonnull
// public List<Commit> getCommits() {
// return commits;
// }
//
// /**
// * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
// * check for whether the data was generated with the same files.
// */
// @Nonnull
// public String getDatasetKey() {
// if (this.datasetKey == null) {
// List<String> filenames = new ArrayList<>(getFilenames());
// Collections.sort(filenames);
// HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
// for (String filename : filenames) {
// hashCodeBuilder.append(filename);
// }
// this.datasetKey = hashCodeBuilder.build().toString();
// }
//
// return this.datasetKey;
// }
//
// @Nonnull
// public QueryData anonymize() {
// CommitAnonymizer anonymizer = new CommitAnonymizer();
// List<Commit> anonymizedCommits = anonymizer.process(commits);
// return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
// }
//
// public GerritVersion getMinGerritVersion() {
// return minVersion;
// }
// }
// Path: GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java
import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.processors;
public abstract class CommitDataProcessor<T> {
@Nonnull | private final CommitFilter filter; |
holmari/gerritstats | GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java | // Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
//
// @Nonnull
// private final List<String> includedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> excludedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> includedBranches = new ArrayList<>();
//
// private boolean includeEmptyEmails;
//
// CommitFilter() {
// }
//
// public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
// this.includedEmails.addAll(excludeEmails);
// }
//
// public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
// this.excludedEmails.addAll(excludeEmails);
// }
//
// public void setIncludeBranches(@Nonnull List<String> includeBranches) {
// this.includedBranches.addAll(includeBranches);
// }
//
// public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
// this.includeEmptyEmails = includeEmptyEmails;
// }
//
// public boolean isIncluded(@Nonnull Commit commit) {
// return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
// }
//
// public boolean isIncluded(@Nullable Commit.Identity identity) {
// if (identity == null || identity.email == null) {
// return includeEmptyEmails;
// } else {
// if (!includedEmails.isEmpty()) {
// return includedEmails.contains(identity.email);
// } else {
// return !excludedEmails.contains(identity.email);
// }
// }
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
//
// public static final int INVALID_PATCH_COUNT = -1;
//
// @Nonnull
// private final CommandLineParser commandLine;
//
// OutputRules(@Nonnull CommandLineParser commandLine) {
// this.commandLine = commandLine;
// }
//
// public String getOutputDir() {
// return commandLine.getOutputDir();
// }
//
// public boolean isAnonymizeDataEnabled() {
// return commandLine.isAnonymizeDataEnabled();
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
// @Nonnull
// private final List<Commit> commits;
// @Nonnull
// private final List<String> filenames;
// @Nonnull
// private final GerritVersion minVersion;
//
// @Nonnull
// private final List<String> branches;
//
// private String datasetKey;
//
// QueryData(@Nonnull List<String> filenames,
// @Nonnull List<Commit> commits,
// @Nonnull GerritVersion minVersion) {
//
// this.filenames = ImmutableList.copyOf(filenames);
// this.commits = ImmutableList.copyOf(commits);
// this.minVersion = minVersion;
// this.branches = this.commits.stream().map(commit -> commit.branch)
// .distinct().collect(Collectors.toList());
// }
//
// public String getDisplayableProjectName() {
// return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
// }
//
// @Nonnull
// public List<String> getFilenames() {
// return this.filenames;
// }
//
// public List<String> getBranches() {
// return this.branches;
// }
//
// @Nonnull
// public List<Commit> getCommits() {
// return commits;
// }
//
// /**
// * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
// * check for whether the data was generated with the same files.
// */
// @Nonnull
// public String getDatasetKey() {
// if (this.datasetKey == null) {
// List<String> filenames = new ArrayList<>(getFilenames());
// Collections.sort(filenames);
// HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
// for (String filename : filenames) {
// hashCodeBuilder.append(filename);
// }
// this.datasetKey = hashCodeBuilder.build().toString();
// }
//
// return this.datasetKey;
// }
//
// @Nonnull
// public QueryData anonymize() {
// CommitAnonymizer anonymizer = new CommitAnonymizer();
// List<Commit> anonymizedCommits = anonymizer.process(commits);
// return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
// }
//
// public GerritVersion getMinGerritVersion() {
// return minVersion;
// }
// }
| import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull; | package com.holmsted.gerrit.processors;
public abstract class CommitDataProcessor<T> {
@Nonnull
private final CommitFilter filter;
@Nonnull | // Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
//
// @Nonnull
// private final List<String> includedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> excludedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> includedBranches = new ArrayList<>();
//
// private boolean includeEmptyEmails;
//
// CommitFilter() {
// }
//
// public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
// this.includedEmails.addAll(excludeEmails);
// }
//
// public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
// this.excludedEmails.addAll(excludeEmails);
// }
//
// public void setIncludeBranches(@Nonnull List<String> includeBranches) {
// this.includedBranches.addAll(includeBranches);
// }
//
// public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
// this.includeEmptyEmails = includeEmptyEmails;
// }
//
// public boolean isIncluded(@Nonnull Commit commit) {
// return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
// }
//
// public boolean isIncluded(@Nullable Commit.Identity identity) {
// if (identity == null || identity.email == null) {
// return includeEmptyEmails;
// } else {
// if (!includedEmails.isEmpty()) {
// return includedEmails.contains(identity.email);
// } else {
// return !excludedEmails.contains(identity.email);
// }
// }
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
//
// public static final int INVALID_PATCH_COUNT = -1;
//
// @Nonnull
// private final CommandLineParser commandLine;
//
// OutputRules(@Nonnull CommandLineParser commandLine) {
// this.commandLine = commandLine;
// }
//
// public String getOutputDir() {
// return commandLine.getOutputDir();
// }
//
// public boolean isAnonymizeDataEnabled() {
// return commandLine.isAnonymizeDataEnabled();
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
// @Nonnull
// private final List<Commit> commits;
// @Nonnull
// private final List<String> filenames;
// @Nonnull
// private final GerritVersion minVersion;
//
// @Nonnull
// private final List<String> branches;
//
// private String datasetKey;
//
// QueryData(@Nonnull List<String> filenames,
// @Nonnull List<Commit> commits,
// @Nonnull GerritVersion minVersion) {
//
// this.filenames = ImmutableList.copyOf(filenames);
// this.commits = ImmutableList.copyOf(commits);
// this.minVersion = minVersion;
// this.branches = this.commits.stream().map(commit -> commit.branch)
// .distinct().collect(Collectors.toList());
// }
//
// public String getDisplayableProjectName() {
// return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
// }
//
// @Nonnull
// public List<String> getFilenames() {
// return this.filenames;
// }
//
// public List<String> getBranches() {
// return this.branches;
// }
//
// @Nonnull
// public List<Commit> getCommits() {
// return commits;
// }
//
// /**
// * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
// * check for whether the data was generated with the same files.
// */
// @Nonnull
// public String getDatasetKey() {
// if (this.datasetKey == null) {
// List<String> filenames = new ArrayList<>(getFilenames());
// Collections.sort(filenames);
// HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
// for (String filename : filenames) {
// hashCodeBuilder.append(filename);
// }
// this.datasetKey = hashCodeBuilder.build().toString();
// }
//
// return this.datasetKey;
// }
//
// @Nonnull
// public QueryData anonymize() {
// CommitAnonymizer anonymizer = new CommitAnonymizer();
// List<Commit> anonymizedCommits = anonymizer.process(commits);
// return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
// }
//
// public GerritVersion getMinGerritVersion() {
// return minVersion;
// }
// }
// Path: GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java
import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.processors;
public abstract class CommitDataProcessor<T> {
@Nonnull
private final CommitFilter filter;
@Nonnull | private final OutputRules outputRules; |
holmari/gerritstats | GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java | // Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
//
// @Nonnull
// private final List<String> includedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> excludedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> includedBranches = new ArrayList<>();
//
// private boolean includeEmptyEmails;
//
// CommitFilter() {
// }
//
// public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
// this.includedEmails.addAll(excludeEmails);
// }
//
// public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
// this.excludedEmails.addAll(excludeEmails);
// }
//
// public void setIncludeBranches(@Nonnull List<String> includeBranches) {
// this.includedBranches.addAll(includeBranches);
// }
//
// public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
// this.includeEmptyEmails = includeEmptyEmails;
// }
//
// public boolean isIncluded(@Nonnull Commit commit) {
// return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
// }
//
// public boolean isIncluded(@Nullable Commit.Identity identity) {
// if (identity == null || identity.email == null) {
// return includeEmptyEmails;
// } else {
// if (!includedEmails.isEmpty()) {
// return includedEmails.contains(identity.email);
// } else {
// return !excludedEmails.contains(identity.email);
// }
// }
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
//
// public static final int INVALID_PATCH_COUNT = -1;
//
// @Nonnull
// private final CommandLineParser commandLine;
//
// OutputRules(@Nonnull CommandLineParser commandLine) {
// this.commandLine = commandLine;
// }
//
// public String getOutputDir() {
// return commandLine.getOutputDir();
// }
//
// public boolean isAnonymizeDataEnabled() {
// return commandLine.isAnonymizeDataEnabled();
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
// @Nonnull
// private final List<Commit> commits;
// @Nonnull
// private final List<String> filenames;
// @Nonnull
// private final GerritVersion minVersion;
//
// @Nonnull
// private final List<String> branches;
//
// private String datasetKey;
//
// QueryData(@Nonnull List<String> filenames,
// @Nonnull List<Commit> commits,
// @Nonnull GerritVersion minVersion) {
//
// this.filenames = ImmutableList.copyOf(filenames);
// this.commits = ImmutableList.copyOf(commits);
// this.minVersion = minVersion;
// this.branches = this.commits.stream().map(commit -> commit.branch)
// .distinct().collect(Collectors.toList());
// }
//
// public String getDisplayableProjectName() {
// return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
// }
//
// @Nonnull
// public List<String> getFilenames() {
// return this.filenames;
// }
//
// public List<String> getBranches() {
// return this.branches;
// }
//
// @Nonnull
// public List<Commit> getCommits() {
// return commits;
// }
//
// /**
// * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
// * check for whether the data was generated with the same files.
// */
// @Nonnull
// public String getDatasetKey() {
// if (this.datasetKey == null) {
// List<String> filenames = new ArrayList<>(getFilenames());
// Collections.sort(filenames);
// HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
// for (String filename : filenames) {
// hashCodeBuilder.append(filename);
// }
// this.datasetKey = hashCodeBuilder.build().toString();
// }
//
// return this.datasetKey;
// }
//
// @Nonnull
// public QueryData anonymize() {
// CommitAnonymizer anonymizer = new CommitAnonymizer();
// List<Commit> anonymizedCommits = anonymizer.process(commits);
// return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
// }
//
// public GerritVersion getMinGerritVersion() {
// return minVersion;
// }
// }
| import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull; | package com.holmsted.gerrit.processors;
public abstract class CommitDataProcessor<T> {
@Nonnull
private final CommitFilter filter;
@Nonnull
private final OutputRules outputRules;
public interface OutputFormatter<T> {
void format(@Nonnull T format);
}
public CommitDataProcessor(@Nonnull CommitFilter filter, @Nonnull OutputRules outputRules) {
this.filter = filter;
this.outputRules = outputRules;
}
/**
* Processes the list of commits and builds output for it,
* returning it as a string.
*/ | // Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
//
// @Nonnull
// private final List<String> includedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> excludedEmails = new ArrayList<>();
// @Nonnull
// private final List<String> includedBranches = new ArrayList<>();
//
// private boolean includeEmptyEmails;
//
// CommitFilter() {
// }
//
// public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
// this.includedEmails.addAll(excludeEmails);
// }
//
// public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
// this.excludedEmails.addAll(excludeEmails);
// }
//
// public void setIncludeBranches(@Nonnull List<String> includeBranches) {
// this.includedBranches.addAll(includeBranches);
// }
//
// public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
// this.includeEmptyEmails = includeEmptyEmails;
// }
//
// public boolean isIncluded(@Nonnull Commit commit) {
// return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
// }
//
// public boolean isIncluded(@Nullable Commit.Identity identity) {
// if (identity == null || identity.email == null) {
// return includeEmptyEmails;
// } else {
// if (!includedEmails.isEmpty()) {
// return includedEmails.contains(identity.email);
// } else {
// return !excludedEmails.contains(identity.email);
// }
// }
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
//
// public static final int INVALID_PATCH_COUNT = -1;
//
// @Nonnull
// private final CommandLineParser commandLine;
//
// OutputRules(@Nonnull CommandLineParser commandLine) {
// this.commandLine = commandLine;
// }
//
// public String getOutputDir() {
// return commandLine.getOutputDir();
// }
//
// public boolean isAnonymizeDataEnabled() {
// return commandLine.isAnonymizeDataEnabled();
// }
// }
//
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
// @Nonnull
// private final List<Commit> commits;
// @Nonnull
// private final List<String> filenames;
// @Nonnull
// private final GerritVersion minVersion;
//
// @Nonnull
// private final List<String> branches;
//
// private String datasetKey;
//
// QueryData(@Nonnull List<String> filenames,
// @Nonnull List<Commit> commits,
// @Nonnull GerritVersion minVersion) {
//
// this.filenames = ImmutableList.copyOf(filenames);
// this.commits = ImmutableList.copyOf(commits);
// this.minVersion = minVersion;
// this.branches = this.commits.stream().map(commit -> commit.branch)
// .distinct().collect(Collectors.toList());
// }
//
// public String getDisplayableProjectName() {
// return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
// }
//
// @Nonnull
// public List<String> getFilenames() {
// return this.filenames;
// }
//
// public List<String> getBranches() {
// return this.branches;
// }
//
// @Nonnull
// public List<Commit> getCommits() {
// return commits;
// }
//
// /**
// * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
// * check for whether the data was generated with the same files.
// */
// @Nonnull
// public String getDatasetKey() {
// if (this.datasetKey == null) {
// List<String> filenames = new ArrayList<>(getFilenames());
// Collections.sort(filenames);
// HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
// for (String filename : filenames) {
// hashCodeBuilder.append(filename);
// }
// this.datasetKey = hashCodeBuilder.build().toString();
// }
//
// return this.datasetKey;
// }
//
// @Nonnull
// public QueryData anonymize() {
// CommitAnonymizer anonymizer = new CommitAnonymizer();
// List<Commit> anonymizedCommits = anonymizer.process(commits);
// return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
// }
//
// public GerritVersion getMinGerritVersion() {
// return minVersion;
// }
// }
// Path: GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java
import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.processors;
public abstract class CommitDataProcessor<T> {
@Nonnull
private final CommitFilter filter;
@Nonnull
private final OutputRules outputRules;
public interface OutputFormatter<T> {
void format(@Nonnull T format);
}
public CommitDataProcessor(@Nonnull CommitFilter filter, @Nonnull OutputRules outputRules) {
this.filter = filter;
this.outputRules = outputRules;
}
/**
* Processes the list of commits and builds output for it,
* returning it as a string.
*/ | public void invoke(@Nonnull QueryData queryData) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/window/NoWindow.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVDataManipulator.java
// @FunctionalInterface
// public interface HRVDataManipulator {
//
// /**
// * Manipulates the given data and returns the manipulated data. The given data must at least contain three data-points.
// * @param data data to manipulate.
// * @return Manipulated data.
// */
// RRData manipulate(RRData data);
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.manipulator.HRVDataManipulator; | package hrv.lib.hrv.calc.manipulator.window;
public class NoWindow implements HRVDataManipulator {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVDataManipulator.java
// @FunctionalInterface
// public interface HRVDataManipulator {
//
// /**
// * Manipulates the given data and returns the manipulated data. The given data must at least contain three data-points.
// * @param data data to manipulate.
// * @return Manipulated data.
// */
// RRData manipulate(RRData data);
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/window/NoWindow.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.manipulator.HRVDataManipulator;
package hrv.lib.hrv.calc.manipulator.window;
public class NoWindow implements HRVDataManipulator {
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/RRDataTest.java | // Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv;
class RRDataTest {
@Test
void testCreation() {
double[] intervalData = new double[] {1.0, 1.0, 2.5, 1.0}; | // Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/RRDataTest.java
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv;
class RRDataTest {
@Test
void testCreation() {
double[] intervalData = new double[] {1.0, 1.0, 2.5, 1.0}; | RRData result = RRData.createFromRRInterval(intervalData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/SDSDCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; | package hrv.lib.hrv.calc.parameter;
public class SDSDCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/SDSDCalculator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
package hrv.lib.hrv.calc.parameter;
public class SDSDCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVDataManipulator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.manipulator;
@FunctionalInterface
public interface HRVDataManipulator {
/**
* Manipulates the given data and returns the manipulated data. The given data must at least contain three data-points.
* @param data data to manipulate.
* @return Manipulated data.
*/ | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVDataManipulator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.manipulator;
@FunctionalInterface
public interface HRVDataManipulator {
/**
* Manipulates the given data and returns the manipulated data. The given data must at least contain three data-points.
* @param data data to manipulate.
* @return Manipulated data.
*/ | RRData manipulate(RRData data); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/MxDMnCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class MxDMnCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.5, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/MxDMnCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class MxDMnCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.5, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/MxDMnCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class MxDMnCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.5, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/MxDMnCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class MxDMnCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.5, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/algorithm/FindIndexOfClosestValueSortedTest.java | // Path: lib/src/main/java/hrv/lib/algorithm/search/FindIndexOfClosestValueSorted.java
// public class FindIndexOfClosestValueSorted {
//
// /**
// * Finds the index with the value whose distance
// * to the given {@code value} is the shortest
// *
// * @param array Sorted array to search the index in
// * @param value value to which the index of the value with the shortest distance is searched to
// * @return index with the shortest distance to {@code value}
// */
// public int findClosestIndexInSortedArray(double[] array, double value) {
// //Set closest index to last index
// int closestIndex = array.length;
//
// //Set closest distance to maximum distance
// double closestDistance = Math.abs(array[array.length - 1] - array[0]);
//
// //find index with closest distance
// for (var i = 0; i < array.length; i++) {
// double distance = Math.abs(array[i] - value);
//
// if (distance < closestDistance) {
// closestIndex = i;
// closestDistance = distance;
// }
// }
//
// return closestIndex;
// }
// }
| import hrv.lib.algorithm.search.FindIndexOfClosestValueSorted;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.algorithm;
class FindIndexOfClosestValueSortedTest {
@Test
void testFindIndexOfClosestValueSorted() {
double[] array = new double[] {2,3,4,5,6,7,8,9,100,101};
| // Path: lib/src/main/java/hrv/lib/algorithm/search/FindIndexOfClosestValueSorted.java
// public class FindIndexOfClosestValueSorted {
//
// /**
// * Finds the index with the value whose distance
// * to the given {@code value} is the shortest
// *
// * @param array Sorted array to search the index in
// * @param value value to which the index of the value with the shortest distance is searched to
// * @return index with the shortest distance to {@code value}
// */
// public int findClosestIndexInSortedArray(double[] array, double value) {
// //Set closest index to last index
// int closestIndex = array.length;
//
// //Set closest distance to maximum distance
// double closestDistance = Math.abs(array[array.length - 1] - array[0]);
//
// //find index with closest distance
// for (var i = 0; i < array.length; i++) {
// double distance = Math.abs(array[i] - value);
//
// if (distance < closestDistance) {
// closestIndex = i;
// closestDistance = distance;
// }
// }
//
// return closestIndex;
// }
// }
// Path: lib/src/test/java/hrv/lib/algorithm/FindIndexOfClosestValueSortedTest.java
import hrv.lib.algorithm.search.FindIndexOfClosestValueSorted;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.algorithm;
class FindIndexOfClosestValueSortedTest {
@Test
void testFindIndexOfClosestValueSorted() {
double[] array = new double[] {2,3,4,5,6,7,8,9,100,101};
| FindIndexOfClosestValueSorted indexFinder = new FindIndexOfClosestValueSorted(); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVPowerSpectrumProcessor.java
// @FunctionalInterface
// public interface HRVPowerSpectrumProcessor {
//
// HRVParameter process(PowerSpectrum ps);
// }
| import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.hrv.calc.parameter.HRVPowerSpectrumProcessor;
import org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator;
import org.apache.commons.math3.analysis.integration.TrapezoidIntegrator; | package hrv.lib.hrv.calc.psd;
public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
private final double lowerIntegrationLimit;
private final double upperIntegrationLimit;
public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
this.lowerIntegrationLimit = lowerIntegrationLimit;
this.upperIntegrationLimit = upperIntegrationLimit;
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVPowerSpectrumProcessor.java
// @FunctionalInterface
// public interface HRVPowerSpectrumProcessor {
//
// HRVParameter process(PowerSpectrum ps);
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.hrv.calc.parameter.HRVPowerSpectrumProcessor;
import org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator;
import org.apache.commons.math3.analysis.integration.TrapezoidIntegrator;
package hrv.lib.hrv.calc.psd;
public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
private final double lowerIntegrationLimit;
private final double upperIntegrationLimit;
public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
this.lowerIntegrationLimit = lowerIntegrationLimit;
this.upperIntegrationLimit = upperIntegrationLimit;
}
@Override | public HRVParameter process(PowerSpectrum ps) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVPowerSpectrumProcessor.java
// @FunctionalInterface
// public interface HRVPowerSpectrumProcessor {
//
// HRVParameter process(PowerSpectrum ps);
// }
| import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.hrv.calc.parameter.HRVPowerSpectrumProcessor;
import org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator;
import org.apache.commons.math3.analysis.integration.TrapezoidIntegrator; | package hrv.lib.hrv.calc.psd;
public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
private final double lowerIntegrationLimit;
private final double upperIntegrationLimit;
public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
this.lowerIntegrationLimit = lowerIntegrationLimit;
this.upperIntegrationLimit = upperIntegrationLimit;
}
@Override
public HRVParameter process(PowerSpectrum ps) {
var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
var integrator = new TrapezoidIntegrator(); | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVPowerSpectrumProcessor.java
// @FunctionalInterface
// public interface HRVPowerSpectrumProcessor {
//
// HRVParameter process(PowerSpectrum ps);
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.hrv.calc.parameter.HRVPowerSpectrumProcessor;
import org.apache.commons.math3.analysis.integration.BaseAbstractUnivariateIntegrator;
import org.apache.commons.math3.analysis.integration.TrapezoidIntegrator;
package hrv.lib.hrv.calc.psd;
public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
private final double lowerIntegrationLimit;
private final double upperIntegrationLimit;
public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
this.lowerIntegrationLimit = lowerIntegrationLimit;
this.upperIntegrationLimit = upperIntegrationLimit;
}
@Override
public HRVParameter process(PowerSpectrum ps) {
var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
var integrator = new TrapezoidIntegrator(); | return new HRVParameter(HRVParameterEnum.NON, |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/RMSSDCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class RMSSDCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/RMSSDCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class RMSSDCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/RMSSDCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class RMSSDCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/RMSSDCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class RMSSDCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/LFnuCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral lf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class LFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public LFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/LFnuCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral lf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class LFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public LFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override | public HRVParameter process(PowerSpectrum ps) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/LFnuCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral lf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class LFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public LFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override
public HRVParameter process(PowerSpectrum ps) { | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/LFnuCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral lf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class LFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public LFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override
public HRVParameter process(PowerSpectrum ps) { | var calcLf = new PowerSpectrumIntegralCalculator(lfLowerLimit, lfUpperLimit); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVZeroPaddingManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVZeroPaddingManipulatorTest {
@Test
void testPadding() {
double[] time2 = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 };
double[] values2 = new double[] { 1.0, 1.1, 1.2, 0.9, 1.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVZeroPaddingManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVZeroPaddingManipulatorTest {
@Test
void testPadding() {
double[] time2 = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 };
double[] values2 = new double[] { 1.0, 1.1, 1.2, 0.9, 1.0 }; | RRData data2 = new RRData(time2, TimeUnit.SECOND, values2, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVZeroPaddingManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVZeroPaddingManipulatorTest {
@Test
void testPadding() {
double[] time2 = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 };
double[] values2 = new double[] { 1.0, 1.1, 1.2, 0.9, 1.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVZeroPaddingManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVZeroPaddingManipulatorTest {
@Test
void testPadding() {
double[] time2 = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0 };
double[] values2 = new double[] { 1.0, 1.1, 1.2, 0.9, 1.0 }; | RRData data2 = new RRData(time2, TimeUnit.SECOND, values2, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/HRVParameterTest.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
| import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; | package hrv.lib.hrv;
class HRVParameterTest {
@Test
void creationTests() {
| // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
// Path: lib/src/test/java/hrv/lib/hrv/HRVParameterTest.java
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
package hrv.lib.hrv;
class HRVParameterTest {
@Test
void creationTests() {
| HRVParameter param1 = new HRVParameter(); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/HRVParameterTest.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
| import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; | package hrv.lib.hrv;
class HRVParameterTest {
@Test
void creationTests() {
HRVParameter param1 = new HRVParameter();
assertEquals(0.0, param1.getValue(), 0.000001);
assertNull(param1.getUnit());
param1.setUnit("ms");
assertEquals("ms", param1.getUnit());
param1.setValue(1.0);
assertEquals(1.0, param1.getValue(), 0.000001);
| // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
// Path: lib/src/test/java/hrv/lib/hrv/HRVParameterTest.java
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
package hrv.lib.hrv;
class HRVParameterTest {
@Test
void creationTests() {
HRVParameter param1 = new HRVParameter();
assertEquals(0.0, param1.getValue(), 0.000001);
assertNull(param1.getUnit());
param1.setUnit("ms");
assertEquals("ms", param1.getUnit());
param1.setValue(1.0);
assertEquals(1.0, param1.getValue(), 0.000001);
| HRVParameter param2 = new HRVParameter(HRVParameterEnum.BAEVSKY, 2.0, "s"); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/ModeCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.parameter;
public class ModeCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/ModeCalculator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.parameter;
public class ModeCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/SD1SD2Calculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.parameter;
public class SD1SD2Calculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/SD1SD2Calculator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.parameter;
public class SD1SD2Calculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/window/WindowTests.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator.window;
class WindowTests {
@Test
void testNoWindow() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/window/WindowTests.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator.window;
class WindowTests {
@Test
void testNoWindow() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | RRData data = new RRData(time1, TimeUnit.SECOND, values1, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/window/WindowTests.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator.window;
class WindowTests {
@Test
void testNoWindow() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/window/WindowTests.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator.window;
class WindowTests {
@Test
void testNoWindow() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | RRData data = new RRData(time1, TimeUnit.SECOND, values1, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/NN50Calculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the NN50 parameter from the given RR-interval-data.
* @author Julian
*
*/
public class NN50Calculator implements HRVDataProcessor {
/**
* Calculates the NN50 parameter from the given rr-interval-data.
* @param data RR-interval-data in seconds
* @return calculated NN50 parameter
*/
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/NN50Calculator.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the NN50 parameter from the given RR-interval-data.
* @author Julian
*
*/
public class NN50Calculator implements HRVDataProcessor {
/**
* Calculates the NN50 parameter from the given rr-interval-data.
* @param data RR-interval-data in seconds
* @return calculated NN50 parameter
*/
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/NN50Calculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the NN50 parameter from the given RR-interval-data.
* @author Julian
*
*/
public class NN50Calculator implements HRVDataProcessor {
/**
* Calculates the NN50 parameter from the given rr-interval-data.
* @param data RR-interval-data in seconds
* @return calculated NN50 parameter
*/
@Override
public HRVParameter process(RRData data) {
double[] rr = data.getValueAxis(); | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/NN50Calculator.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the NN50 parameter from the given RR-interval-data.
* @author Julian
*
*/
public class NN50Calculator implements HRVDataProcessor {
/**
* Calculates the NN50 parameter from the given rr-interval-data.
* @param data RR-interval-data in seconds
* @return calculated NN50 parameter
*/
@Override
public HRVParameter process(RRData data) {
double[] rr = data.getValueAxis(); | double threshold = data.getValueAxisUnit() == TimeUnit.SECOND ? 0.05 : 50; //50 ms |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVFilterOutlierTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVFilterOutlierTest {
@Test
void testManipulate() {
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVFilterOutlierTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVFilterOutlierTest {
@Test
void testManipulate() {
| RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1,1,1}, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVFilterOutlierTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVFilterOutlierTest {
@Test
void testManipulate() {
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVFilterOutlierTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVFilterOutlierTest {
@Test
void testManipulate() {
| RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1,1,1}, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/LFCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
public class LFCalculator implements HRVPowerSpectrumProcessor {
private static final double LF_LOWER_BOUND = 0.04;
private static final double LF_UPPER_BOUND = 0.15;
@Override | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/LFCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
public class LFCalculator implements HRVPowerSpectrumProcessor {
private static final double LF_LOWER_BOUND = 0.04;
private static final double LF_UPPER_BOUND = 0.15;
@Override | public HRVParameter process(PowerSpectrum ps) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/LFCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
public class LFCalculator implements HRVPowerSpectrumProcessor {
private static final double LF_LOWER_BOUND = 0.04;
private static final double LF_UPPER_BOUND = 0.15;
@Override
public HRVParameter process(PowerSpectrum ps) { | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/LFCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
public class LFCalculator implements HRVPowerSpectrumProcessor {
private static final double LF_LOWER_BOUND = 0.04;
private static final double LF_UPPER_BOUND = 0.15;
@Override
public HRVParameter process(PowerSpectrum ps) { | var calcLF = new PowerSpectrumIntegralCalculator(LF_LOWER_BOUND, LF_UPPER_BOUND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVCutToPowerTwoDataManipulatorTest {
@Test
void testCutWithSameNum() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVCutToPowerTwoDataManipulatorTest {
@Test
void testCutWithSameNum() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | RRData data = new RRData(time1, TimeUnit.SECOND, values1, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVCutToPowerTwoDataManipulatorTest {
@Test
void testCutWithSameNum() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVCutToPowerTwoDataManipulatorTest {
@Test
void testCutWithSameNum() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 1.0, 1.1, 1.2, 0.9 }; | RRData data = new RRData(time1, TimeUnit.SECOND, values1, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/HRVLibFacade.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
// public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
//
// /**
// * Calculates the power spectrum density (PSD) of the given
// * rr-interval-data. The sampling rate is used to sample the interpolated
// * rr-interval-data.
// *
// * @param rr
// * rr-interval-data in seconds
// * @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
// */
// @Override
// public PowerSpectrum calculateEstimate(RRData rr) {
// double[] power = calculatePower(rr);
// double[] frequencies = calculateFrequencies(rr);
//
// return new PowerSpectrum(power, frequencies);
// }
//
// private double[] calculatePower(RRData rr) {
// double[] rrY = rr.getValueAxis();
// var calc = new AvgSampleSizeCalculator();
// double avgSampleSize = calc.process(rr).getValue();
//
// final var fft = new FastFourierTransformer(DftNormalization.STANDARD);
// final Complex[] fftResult = fft.transform(rrY, TransformType.FORWARD);
//
// // Calculate the power spectral density of the Fourier Transform
// var betrag = new double[rrY.length];
// for (var i = 0; i < rrY.length; i++) {
// //Calculate power spectral density
// //Unit: s*s / Hz = s*s*s
// double abs = fftResult[i].abs();
// betrag[i] = abs * abs / (rrY.length * (1 / avgSampleSize) * 0.5);
// }
//
// return betrag;
// }
//
// private double[] calculateFrequencies(RRData rr) {
// var calc = new AvgSampleSizeCalculator();
// double sampleFrequency = 1 / calc.process(rr).getValue();
// double maxSampleFrequency = 0.5 * sampleFrequency;
//
// // Calculate Frequencies to corresponding power values
// // Frequency Steps in Hz
// double frequencySteps = (2 * maxSampleFrequency) / (rr.getTimeAxis().length);
// var frequencies = new double[rr.getTimeAxis().length];
//
// for (var i = 0; i < frequencies.length; i++) {
// frequencies[i] = (frequencySteps) * i;
// }
//
// return frequencies;
// }
// }
| import hrv.lib.hrv.calc.manipulator.*;
import hrv.lib.hrv.calc.parameter.*;
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.StandardPowerSpectralDensityEstimator;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set; | * Calculates the HRV-Parameters specified in {@code parameters} for the
* given RR-Data.
*
* @return List of HRV-Parameters
*/
public List<HRVParameter> calculateParameters() {
RRData filteredData = filters.manipulate(data);
List<HRVParameter> allParams = new ArrayList<>();
List<HRVDataProcessor> allCalculators = getAllHRVDataProcessors();
for (HRVDataProcessor p : allCalculators) {
allParams.add(p.process(filteredData));
}
if (containsOne(frequencyParams, parameters)) {
allParams.addAll(calculateFrequencyParams(filteredData));
}
return allParams;
}
/**
* Calculates the power spectrum of the given data.
*
* @param data
* Data to calculate the power spectrum from
* @return power spectrum
*/ | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
// public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
//
// /**
// * Calculates the power spectrum density (PSD) of the given
// * rr-interval-data. The sampling rate is used to sample the interpolated
// * rr-interval-data.
// *
// * @param rr
// * rr-interval-data in seconds
// * @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
// */
// @Override
// public PowerSpectrum calculateEstimate(RRData rr) {
// double[] power = calculatePower(rr);
// double[] frequencies = calculateFrequencies(rr);
//
// return new PowerSpectrum(power, frequencies);
// }
//
// private double[] calculatePower(RRData rr) {
// double[] rrY = rr.getValueAxis();
// var calc = new AvgSampleSizeCalculator();
// double avgSampleSize = calc.process(rr).getValue();
//
// final var fft = new FastFourierTransformer(DftNormalization.STANDARD);
// final Complex[] fftResult = fft.transform(rrY, TransformType.FORWARD);
//
// // Calculate the power spectral density of the Fourier Transform
// var betrag = new double[rrY.length];
// for (var i = 0; i < rrY.length; i++) {
// //Calculate power spectral density
// //Unit: s*s / Hz = s*s*s
// double abs = fftResult[i].abs();
// betrag[i] = abs * abs / (rrY.length * (1 / avgSampleSize) * 0.5);
// }
//
// return betrag;
// }
//
// private double[] calculateFrequencies(RRData rr) {
// var calc = new AvgSampleSizeCalculator();
// double sampleFrequency = 1 / calc.process(rr).getValue();
// double maxSampleFrequency = 0.5 * sampleFrequency;
//
// // Calculate Frequencies to corresponding power values
// // Frequency Steps in Hz
// double frequencySteps = (2 * maxSampleFrequency) / (rr.getTimeAxis().length);
// var frequencies = new double[rr.getTimeAxis().length];
//
// for (var i = 0; i < frequencies.length; i++) {
// frequencies[i] = (frequencySteps) * i;
// }
//
// return frequencies;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/HRVLibFacade.java
import hrv.lib.hrv.calc.manipulator.*;
import hrv.lib.hrv.calc.parameter.*;
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.StandardPowerSpectralDensityEstimator;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
* Calculates the HRV-Parameters specified in {@code parameters} for the
* given RR-Data.
*
* @return List of HRV-Parameters
*/
public List<HRVParameter> calculateParameters() {
RRData filteredData = filters.manipulate(data);
List<HRVParameter> allParams = new ArrayList<>();
List<HRVDataProcessor> allCalculators = getAllHRVDataProcessors();
for (HRVDataProcessor p : allCalculators) {
allParams.add(p.process(filteredData));
}
if (containsOne(frequencyParams, parameters)) {
allParams.addAll(calculateFrequencyParams(filteredData));
}
return allParams;
}
/**
* Calculates the power spectrum of the given data.
*
* @param data
* Data to calculate the power spectrum from
* @return power spectrum
*/ | public PowerSpectrum getPowerSpectrum(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/HRVLibFacade.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
// public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
//
// /**
// * Calculates the power spectrum density (PSD) of the given
// * rr-interval-data. The sampling rate is used to sample the interpolated
// * rr-interval-data.
// *
// * @param rr
// * rr-interval-data in seconds
// * @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
// */
// @Override
// public PowerSpectrum calculateEstimate(RRData rr) {
// double[] power = calculatePower(rr);
// double[] frequencies = calculateFrequencies(rr);
//
// return new PowerSpectrum(power, frequencies);
// }
//
// private double[] calculatePower(RRData rr) {
// double[] rrY = rr.getValueAxis();
// var calc = new AvgSampleSizeCalculator();
// double avgSampleSize = calc.process(rr).getValue();
//
// final var fft = new FastFourierTransformer(DftNormalization.STANDARD);
// final Complex[] fftResult = fft.transform(rrY, TransformType.FORWARD);
//
// // Calculate the power spectral density of the Fourier Transform
// var betrag = new double[rrY.length];
// for (var i = 0; i < rrY.length; i++) {
// //Calculate power spectral density
// //Unit: s*s / Hz = s*s*s
// double abs = fftResult[i].abs();
// betrag[i] = abs * abs / (rrY.length * (1 / avgSampleSize) * 0.5);
// }
//
// return betrag;
// }
//
// private double[] calculateFrequencies(RRData rr) {
// var calc = new AvgSampleSizeCalculator();
// double sampleFrequency = 1 / calc.process(rr).getValue();
// double maxSampleFrequency = 0.5 * sampleFrequency;
//
// // Calculate Frequencies to corresponding power values
// // Frequency Steps in Hz
// double frequencySteps = (2 * maxSampleFrequency) / (rr.getTimeAxis().length);
// var frequencies = new double[rr.getTimeAxis().length];
//
// for (var i = 0; i < frequencies.length; i++) {
// frequencies[i] = (frequencySteps) * i;
// }
//
// return frequencies;
// }
// }
| import hrv.lib.hrv.calc.manipulator.*;
import hrv.lib.hrv.calc.parameter.*;
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.StandardPowerSpectralDensityEstimator;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set; | *
* @return List of HRV-Parameters
*/
public List<HRVParameter> calculateParameters() {
RRData filteredData = filters.manipulate(data);
List<HRVParameter> allParams = new ArrayList<>();
List<HRVDataProcessor> allCalculators = getAllHRVDataProcessors();
for (HRVDataProcessor p : allCalculators) {
allParams.add(p.process(filteredData));
}
if (containsOne(frequencyParams, parameters)) {
allParams.addAll(calculateFrequencyParams(filteredData));
}
return allParams;
}
/**
* Calculates the power spectrum of the given data.
*
* @param data
* Data to calculate the power spectrum from
* @return power spectrum
*/
public PowerSpectrum getPowerSpectrum(RRData data) {
RRData manipulatedData = frequencyDataManipulator.manipulate(data); | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
// public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
//
// /**
// * Calculates the power spectrum density (PSD) of the given
// * rr-interval-data. The sampling rate is used to sample the interpolated
// * rr-interval-data.
// *
// * @param rr
// * rr-interval-data in seconds
// * @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
// */
// @Override
// public PowerSpectrum calculateEstimate(RRData rr) {
// double[] power = calculatePower(rr);
// double[] frequencies = calculateFrequencies(rr);
//
// return new PowerSpectrum(power, frequencies);
// }
//
// private double[] calculatePower(RRData rr) {
// double[] rrY = rr.getValueAxis();
// var calc = new AvgSampleSizeCalculator();
// double avgSampleSize = calc.process(rr).getValue();
//
// final var fft = new FastFourierTransformer(DftNormalization.STANDARD);
// final Complex[] fftResult = fft.transform(rrY, TransformType.FORWARD);
//
// // Calculate the power spectral density of the Fourier Transform
// var betrag = new double[rrY.length];
// for (var i = 0; i < rrY.length; i++) {
// //Calculate power spectral density
// //Unit: s*s / Hz = s*s*s
// double abs = fftResult[i].abs();
// betrag[i] = abs * abs / (rrY.length * (1 / avgSampleSize) * 0.5);
// }
//
// return betrag;
// }
//
// private double[] calculateFrequencies(RRData rr) {
// var calc = new AvgSampleSizeCalculator();
// double sampleFrequency = 1 / calc.process(rr).getValue();
// double maxSampleFrequency = 0.5 * sampleFrequency;
//
// // Calculate Frequencies to corresponding power values
// // Frequency Steps in Hz
// double frequencySteps = (2 * maxSampleFrequency) / (rr.getTimeAxis().length);
// var frequencies = new double[rr.getTimeAxis().length];
//
// for (var i = 0; i < frequencies.length; i++) {
// frequencies[i] = (frequencySteps) * i;
// }
//
// return frequencies;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/HRVLibFacade.java
import hrv.lib.hrv.calc.manipulator.*;
import hrv.lib.hrv.calc.parameter.*;
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.StandardPowerSpectralDensityEstimator;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
*
* @return List of HRV-Parameters
*/
public List<HRVParameter> calculateParameters() {
RRData filteredData = filters.manipulate(data);
List<HRVParameter> allParams = new ArrayList<>();
List<HRVDataProcessor> allCalculators = getAllHRVDataProcessors();
for (HRVDataProcessor p : allCalculators) {
allParams.add(p.process(filteredData));
}
if (containsOne(frequencyParams, parameters)) {
allParams.addAll(calculateFrequencyParams(filteredData));
}
return allParams;
}
/**
* Calculates the power spectrum of the given data.
*
* @param data
* Data to calculate the power spectrum from
* @return power spectrum
*/
public PowerSpectrum getPowerSpectrum(RRData data) {
RRData manipulatedData = frequencyDataManipulator.manipulate(data); | var estimator = new StandardPowerSpectralDensityEstimator(); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/RMSSDCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.parameter;
public class RMSSDCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/RMSSDCalculator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.parameter;
public class RMSSDCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/psd/PSDEstimatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.psd;
class PSDEstimatorTest {
@Test
void testStandardPSD() {
double sinHz = 1; //Frequency of the sin function
int sampleFrequency = 8; //Sample Frequency in Hz
double xLength = 2; //Length of the data.
double[] sinY = generateSinArray(xLength, sampleFrequency, sinHz);
//Generate X-Axis
double[] sinX = new double[sinY.length];
for(int i = 0; i < sinX.length; i++) {
sinX[i] = i * (1.0 / sampleFrequency);
}
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/psd/PSDEstimatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.psd;
class PSDEstimatorTest {
@Test
void testStandardPSD() {
double sinHz = 1; //Frequency of the sin function
int sampleFrequency = 8; //Sample Frequency in Hz
double xLength = 2; //Length of the data.
double[] sinY = generateSinArray(xLength, sampleFrequency, sinHz);
//Generate X-Axis
double[] sinX = new double[sinY.length];
for(int i = 0; i < sinX.length; i++) {
sinX[i] = i * (1.0 / sampleFrequency);
}
| RRData rr = new RRData(sinX, TimeUnit.SECOND, sinY, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/psd/PSDEstimatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.psd;
class PSDEstimatorTest {
@Test
void testStandardPSD() {
double sinHz = 1; //Frequency of the sin function
int sampleFrequency = 8; //Sample Frequency in Hz
double xLength = 2; //Length of the data.
double[] sinY = generateSinArray(xLength, sampleFrequency, sinHz);
//Generate X-Axis
double[] sinX = new double[sinY.length];
for(int i = 0; i < sinX.length; i++) {
sinX[i] = i * (1.0 / sampleFrequency);
}
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/psd/PSDEstimatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.psd;
class PSDEstimatorTest {
@Test
void testStandardPSD() {
double sinHz = 1; //Frequency of the sin function
int sampleFrequency = 8; //Sample Frequency in Hz
double xLength = 2; //Length of the data.
double[] sinY = generateSinArray(xLength, sampleFrequency, sinHz);
//Generate X-Axis
double[] sinX = new double[sinY.length];
for(int i = 0; i < sinX.length; i++) {
sinX[i] = i * (1.0 / sampleFrequency);
}
| RRData rr = new RRData(sinX, TimeUnit.SECOND, sinY, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/PNN50Calculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the pNN50-HRV-Parameter from the given RR-interval-data.
*
* @author Julian
*
*/
public class PNN50Calculator implements HRVDataProcessor {
/**
* Calculates the pNN50-HRV-Parameter in %, from the given RR-interval-data.
* @return calculated pNN50 parameter.
*/
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/PNN50Calculator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the pNN50-HRV-Parameter from the given RR-interval-data.
*
* @author Julian
*
*/
public class PNN50Calculator implements HRVDataProcessor {
/**
* Calculates the pNN50-HRV-Parameter in %, from the given RR-interval-data.
* @return calculated pNN50 parameter.
*/
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVCutDataManipulator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.manipulator;
/**
* Has the ability to cut a the data in a {@link RRData} object to a specified number.
* The remaining data are the last values in the {@link RRData} arrays
*
* @author Julian
*
*/
public class HRVCutDataManipulator implements HRVDataManipulator {
private final int numToKeep;
public HRVCutDataManipulator(int numToKeep) {
this.numToKeep = numToKeep;
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVCutDataManipulator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.manipulator;
/**
* Has the ability to cut a the data in a {@link RRData} object to a specified number.
* The remaining data are the last values in the {@link RRData} arrays
*
* @author Julian
*
*/
public class HRVCutDataManipulator implements HRVDataManipulator {
private final int numToKeep;
public HRVCutDataManipulator(int numToKeep) {
this.numToKeep = numToKeep;
}
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVMultiDataManipulator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import java.util.ArrayList;
import java.util.List; | package hrv.lib.hrv.calc.manipulator;
public class HRVMultiDataManipulator implements HRVDataManipulator {
private final List<HRVDataManipulator> manipulators = new ArrayList<>();
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVMultiDataManipulator.java
import hrv.lib.hrv.RRData;
import java.util.ArrayList;
import java.util.List;
package hrv.lib.hrv.calc.manipulator;
public class HRVMultiDataManipulator implements HRVDataManipulator {
private final List<HRVDataManipulator> manipulators = new ArrayList<>();
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/continous/HRVContinuousPulseTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.continous;
class HRVContinuousPulseTest {
@Test
void testPulse() { | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/continous/HRVContinuousPulseTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.continous;
class HRVContinuousPulseTest {
@Test
void testPulse() { | RRData data = RRData.createFromRRInterval(new double[] { 1.0, 1.0, 1.0, 1.0 }, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/continous/HRVContinuousPulseTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.continous;
class HRVContinuousPulseTest {
@Test
void testPulse() { | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/continous/HRVContinuousPulseTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.continous;
class HRVContinuousPulseTest {
@Test
void testPulse() { | RRData data = RRData.createFromRRInterval(new double[] { 1.0, 1.0, 1.0, 1.0 }, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/continous/HRVContinuousPulseTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; |
HRVContinuousHeartRate pulseCalc2 = new HRVContinuousHeartRate(6);
assertEquals(30.0, pulseCalc2.process(data2).getValue(), 0.00001);
}
@Test
void testContinuity() {
HRVContinuousHeartRate pulseCalc = new HRVContinuousHeartRate(10);
HRVParameterChangedMockListener listener = new HRVParameterChangedMockListener();
pulseCalc.addHRVParameterChangedListener(listener);
HRVRRIntervalEvent event1 = new HRVRRIntervalEvent();
event1.setRr(1.0);
HRVRRIntervalEvent event2 = new HRVRRIntervalEvent();
event2.setRr(1.0);
HRVRRIntervalEvent event3 = new HRVRRIntervalEvent();
event3.setRr(1.0);
HRVRRIntervalEvent event4 = new HRVRRIntervalEvent();
event4.setRr(1.0);
pulseCalc.newRRInterval(event1);
pulseCalc.newRRInterval(event2);
pulseCalc.newRRInterval(event3);
pulseCalc.newRRInterval(event4);
}
static class HRVParameterChangedMockListener implements HRVParameterChangedListener {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/continous/HRVContinuousPulseTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
HRVContinuousHeartRate pulseCalc2 = new HRVContinuousHeartRate(6);
assertEquals(30.0, pulseCalc2.process(data2).getValue(), 0.00001);
}
@Test
void testContinuity() {
HRVContinuousHeartRate pulseCalc = new HRVContinuousHeartRate(10);
HRVParameterChangedMockListener listener = new HRVParameterChangedMockListener();
pulseCalc.addHRVParameterChangedListener(listener);
HRVRRIntervalEvent event1 = new HRVRRIntervalEvent();
event1.setRr(1.0);
HRVRRIntervalEvent event2 = new HRVRRIntervalEvent();
event2.setRr(1.0);
HRVRRIntervalEvent event3 = new HRVRRIntervalEvent();
event3.setRr(1.0);
HRVRRIntervalEvent event4 = new HRVRRIntervalEvent();
event4.setRr(1.0);
pulseCalc.newRRInterval(event1);
pulseCalc.newRRInterval(event2);
pulseCalc.newRRInterval(event3);
pulseCalc.newRRInterval(event4);
}
static class HRVParameterChangedMockListener implements HRVParameterChangedListener {
@Override | public void parameterChanged(HRVParameter param) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/HFnuCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral hf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class HFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public HFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HFnuCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral hf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class HFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public HFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override | public HRVParameter process(PowerSpectrum ps) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/HFnuCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral hf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class HFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public HFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override
public HRVParameter process(PowerSpectrum ps) {
| // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HFnuCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
/**
* Calculates the normalized unit of the spectral hf indices. Like defined in
* https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1978375/
*
* @author Julian
*
*/
public class HFnuCalculator implements HRVPowerSpectrumProcessor {
private final double lfLowerLimit;
private final double lfUpperLimit;
private final double hfLowerLimit;
private final double hfUpperLimit;
public HFnuCalculator(double lfLowerLimit, double lfUpperLimit, double hfLowerLimit, double hfUpperLimit) {
this.lfLowerLimit = lfLowerLimit;
this.lfUpperLimit = lfUpperLimit;
this.hfLowerLimit = hfLowerLimit;
this.hfUpperLimit = hfUpperLimit;
}
@Override
public HRVParameter process(PowerSpectrum ps) {
| var calcHf = new PowerSpectrumIntegralCalculator(hfLowerLimit, hfUpperLimit); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulator.java | // Path: lib/src/main/java/hrv/lib/common/MathUtils.java
// public class MathUtils {
//
// /**
// * Makes this class a utility class.
// */
// private MathUtils() {}
//
// /**
// * Rounds the given number (value) to places places. With rounding mode half down (5.5 => 5)
// * @param value Value to round
// * @param places Number of places the given number should be rounded to
// * @return rounded number.
// */
// public static double round(double value, int places) {
// if (places < 0)
// throw new IllegalArgumentException();
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, RoundingMode.HALF_DOWN);
// return bd.doubleValue();
// }
//
// public static double round(double value, int places, RoundingMode mode) {
// if (places < 0)
// { throw new IllegalArgumentException(); }
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, mode);
// return bd.doubleValue();
// }
//
// /**
// * Returns the largest number that is a power of two
// * and smaller than the given number (n)
// * @param n given number
// * @return the largest number that is a power of two
// * and smaller than the given number (n)
// */
// public static int largestNumThatIsPowerOf2(int n) {
// return Integer.highestOneBit(n);
// }
//
// public static boolean almostEqual(double a, double b, double eps){
// return Math.abs(a-b)<eps;
// }
//
// public static double[] calculateAverageArray(double[] values, int range) {
// var averages = new double[values.length];
// for(var i = 0; i < values.length; i++){
//
// int leftStart = i < range ? -i : -range;
// var count = 0;
// for(int j = leftStart; j < 0; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// int rightEnd = i + (range + 1) > values.length ? (values.length - i) : range + 1;
// for(var j = 1; j < rightEnd; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// if(count != 0) {
// averages[i] = averages[i] / count;
// }
// }
//
// return averages;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.common.MathUtils;
import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.manipulator;
/**
* Cuts the given data down, so that the resulting length of the data is a power of two.
*
* @author Julian
*
*/
public class HRVCutToPowerTwoDataManipulator implements HRVDataManipulator {
@Override | // Path: lib/src/main/java/hrv/lib/common/MathUtils.java
// public class MathUtils {
//
// /**
// * Makes this class a utility class.
// */
// private MathUtils() {}
//
// /**
// * Rounds the given number (value) to places places. With rounding mode half down (5.5 => 5)
// * @param value Value to round
// * @param places Number of places the given number should be rounded to
// * @return rounded number.
// */
// public static double round(double value, int places) {
// if (places < 0)
// throw new IllegalArgumentException();
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, RoundingMode.HALF_DOWN);
// return bd.doubleValue();
// }
//
// public static double round(double value, int places, RoundingMode mode) {
// if (places < 0)
// { throw new IllegalArgumentException(); }
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, mode);
// return bd.doubleValue();
// }
//
// /**
// * Returns the largest number that is a power of two
// * and smaller than the given number (n)
// * @param n given number
// * @return the largest number that is a power of two
// * and smaller than the given number (n)
// */
// public static int largestNumThatIsPowerOf2(int n) {
// return Integer.highestOneBit(n);
// }
//
// public static boolean almostEqual(double a, double b, double eps){
// return Math.abs(a-b)<eps;
// }
//
// public static double[] calculateAverageArray(double[] values, int range) {
// var averages = new double[values.length];
// for(var i = 0; i < values.length; i++){
//
// int leftStart = i < range ? -i : -range;
// var count = 0;
// for(int j = leftStart; j < 0; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// int rightEnd = i + (range + 1) > values.length ? (values.length - i) : range + 1;
// for(var j = 1; j < rightEnd; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// if(count != 0) {
// averages[i] = averages[i] / count;
// }
// }
//
// return averages;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulator.java
import hrv.lib.common.MathUtils;
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.manipulator;
/**
* Cuts the given data down, so that the resulting length of the data is a power of two.
*
* @author Julian
*
*/
public class HRVCutToPowerTwoDataManipulator implements HRVDataManipulator {
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulator.java | // Path: lib/src/main/java/hrv/lib/common/MathUtils.java
// public class MathUtils {
//
// /**
// * Makes this class a utility class.
// */
// private MathUtils() {}
//
// /**
// * Rounds the given number (value) to places places. With rounding mode half down (5.5 => 5)
// * @param value Value to round
// * @param places Number of places the given number should be rounded to
// * @return rounded number.
// */
// public static double round(double value, int places) {
// if (places < 0)
// throw new IllegalArgumentException();
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, RoundingMode.HALF_DOWN);
// return bd.doubleValue();
// }
//
// public static double round(double value, int places, RoundingMode mode) {
// if (places < 0)
// { throw new IllegalArgumentException(); }
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, mode);
// return bd.doubleValue();
// }
//
// /**
// * Returns the largest number that is a power of two
// * and smaller than the given number (n)
// * @param n given number
// * @return the largest number that is a power of two
// * and smaller than the given number (n)
// */
// public static int largestNumThatIsPowerOf2(int n) {
// return Integer.highestOneBit(n);
// }
//
// public static boolean almostEqual(double a, double b, double eps){
// return Math.abs(a-b)<eps;
// }
//
// public static double[] calculateAverageArray(double[] values, int range) {
// var averages = new double[values.length];
// for(var i = 0; i < values.length; i++){
//
// int leftStart = i < range ? -i : -range;
// var count = 0;
// for(int j = leftStart; j < 0; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// int rightEnd = i + (range + 1) > values.length ? (values.length - i) : range + 1;
// for(var j = 1; j < rightEnd; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// if(count != 0) {
// averages[i] = averages[i] / count;
// }
// }
//
// return averages;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.common.MathUtils;
import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.manipulator;
/**
* Cuts the given data down, so that the resulting length of the data is a power of two.
*
* @author Julian
*
*/
public class HRVCutToPowerTwoDataManipulator implements HRVDataManipulator {
@Override
public RRData manipulate(RRData data) { | // Path: lib/src/main/java/hrv/lib/common/MathUtils.java
// public class MathUtils {
//
// /**
// * Makes this class a utility class.
// */
// private MathUtils() {}
//
// /**
// * Rounds the given number (value) to places places. With rounding mode half down (5.5 => 5)
// * @param value Value to round
// * @param places Number of places the given number should be rounded to
// * @return rounded number.
// */
// public static double round(double value, int places) {
// if (places < 0)
// throw new IllegalArgumentException();
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, RoundingMode.HALF_DOWN);
// return bd.doubleValue();
// }
//
// public static double round(double value, int places, RoundingMode mode) {
// if (places < 0)
// { throw new IllegalArgumentException(); }
//
// var bd = BigDecimal.valueOf(value);
// bd = bd.setScale(places, mode);
// return bd.doubleValue();
// }
//
// /**
// * Returns the largest number that is a power of two
// * and smaller than the given number (n)
// * @param n given number
// * @return the largest number that is a power of two
// * and smaller than the given number (n)
// */
// public static int largestNumThatIsPowerOf2(int n) {
// return Integer.highestOneBit(n);
// }
//
// public static boolean almostEqual(double a, double b, double eps){
// return Math.abs(a-b)<eps;
// }
//
// public static double[] calculateAverageArray(double[] values, int range) {
// var averages = new double[values.length];
// for(var i = 0; i < values.length; i++){
//
// int leftStart = i < range ? -i : -range;
// var count = 0;
// for(int j = leftStart; j < 0; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// int rightEnd = i + (range + 1) > values.length ? (values.length - i) : range + 1;
// for(var j = 1; j < rightEnd; j++) {
// averages[i] += values[i + j];
// count++;
// }
//
// if(count != 0) {
// averages[i] = averages[i] / count;
// }
// }
//
// return averages;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVCutToPowerTwoDataManipulator.java
import hrv.lib.common.MathUtils;
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.manipulator;
/**
* Cuts the given data down, so that the resulting length of the data is a power of two.
*
* @author Julian
*
*/
public class HRVCutToPowerTwoDataManipulator implements HRVDataManipulator {
@Override
public RRData manipulate(RRData data) { | int cutAt = MathUtils.largestNumThatIsPowerOf2(data.getTimeAxis().length); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/continous/HRVParameterChangedListener.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
| import hrv.lib.hrv.calc.parameter.HRVParameter; | package hrv.lib.hrv.calc.continous;
@FunctionalInterface
public interface HRVParameterChangedListener {
| // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/continous/HRVParameterChangedListener.java
import hrv.lib.hrv.calc.parameter.HRVParameter;
package hrv.lib.hrv.calc.continous;
@FunctionalInterface
public interface HRVParameterChangedListener {
| void parameterChanged(HRVParameter param); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCleanRRDataByLimitTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/files/HRVIBIFileReader.java
// public class HRVIBIFileReader {
//
// /**
// * Reads the .ibi file that is specified in {@code filePath} and
// * returns the data in form of a {@code List<Double>}
// * @param filePath File to read
// * @return Read data.
// * @throws IOException throws IOException
// */
// public RRData readIBIFile(String filePath, TimeUnit unit) throws IOException {
// List<Double> rr = new ArrayList<>();
//
// try(var reader = new BufferedReader(new FileReader(filePath))) {
// for(String line; (line = reader.readLine()) != null; ) {
// rr.add(Double.parseDouble(line));
// }
// }
//
// return RRData.createFromRRInterval(ArrayUtils.toPrimitive(rr, 0.0), unit);
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.files.HRVIBIFileReader;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVCleanRRDataByLimitTest {
private RRData dataWithDefects;
private RRData cleanedData;
@BeforeEach
void loadData() throws IOException { | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/files/HRVIBIFileReader.java
// public class HRVIBIFileReader {
//
// /**
// * Reads the .ibi file that is specified in {@code filePath} and
// * returns the data in form of a {@code List<Double>}
// * @param filePath File to read
// * @return Read data.
// * @throws IOException throws IOException
// */
// public RRData readIBIFile(String filePath, TimeUnit unit) throws IOException {
// List<Double> rr = new ArrayList<>();
//
// try(var reader = new BufferedReader(new FileReader(filePath))) {
// for(String line; (line = reader.readLine()) != null; ) {
// rr.add(Double.parseDouble(line));
// }
// }
//
// return RRData.createFromRRInterval(ArrayUtils.toPrimitive(rr, 0.0), unit);
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCleanRRDataByLimitTest.java
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.files.HRVIBIFileReader;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVCleanRRDataByLimitTest {
private RRData dataWithDefects;
private RRData cleanedData;
@BeforeEach
void loadData() throws IOException { | HRVIBIFileReader reader = new HRVIBIFileReader(); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCleanRRDataByLimitTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/files/HRVIBIFileReader.java
// public class HRVIBIFileReader {
//
// /**
// * Reads the .ibi file that is specified in {@code filePath} and
// * returns the data in form of a {@code List<Double>}
// * @param filePath File to read
// * @return Read data.
// * @throws IOException throws IOException
// */
// public RRData readIBIFile(String filePath, TimeUnit unit) throws IOException {
// List<Double> rr = new ArrayList<>();
//
// try(var reader = new BufferedReader(new FileReader(filePath))) {
// for(String line; (line = reader.readLine()) != null; ) {
// rr.add(Double.parseDouble(line));
// }
// }
//
// return RRData.createFromRRInterval(ArrayUtils.toPrimitive(rr, 0.0), unit);
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.files.HRVIBIFileReader;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVCleanRRDataByLimitTest {
private RRData dataWithDefects;
private RRData cleanedData;
@BeforeEach
void loadData() throws IOException {
HRVIBIFileReader reader = new HRVIBIFileReader();
Path currentDirectory = Paths.get(System.getProperty("user.dir"));
Path sampleDataFolderPath = Paths.get(currentDirectory.toString(), "SampleData");
Path dataWithDefectsPath = Paths.get(sampleDataFolderPath.toString(), "RR1_With_Artifacts.ibi");
Path cleanedDataPath = Paths.get(sampleDataFolderPath.toString(), "RR1_Cleaned.ibi");
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/files/HRVIBIFileReader.java
// public class HRVIBIFileReader {
//
// /**
// * Reads the .ibi file that is specified in {@code filePath} and
// * returns the data in form of a {@code List<Double>}
// * @param filePath File to read
// * @return Read data.
// * @throws IOException throws IOException
// */
// public RRData readIBIFile(String filePath, TimeUnit unit) throws IOException {
// List<Double> rr = new ArrayList<>();
//
// try(var reader = new BufferedReader(new FileReader(filePath))) {
// for(String line; (line = reader.readLine()) != null; ) {
// rr.add(Double.parseDouble(line));
// }
// }
//
// return RRData.createFromRRInterval(ArrayUtils.toPrimitive(rr, 0.0), unit);
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCleanRRDataByLimitTest.java
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.files.HRVIBIFileReader;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVCleanRRDataByLimitTest {
private RRData dataWithDefects;
private RRData cleanedData;
@BeforeEach
void loadData() throws IOException {
HRVIBIFileReader reader = new HRVIBIFileReader();
Path currentDirectory = Paths.get(System.getProperty("user.dir"));
Path sampleDataFolderPath = Paths.get(currentDirectory.toString(), "SampleData");
Path dataWithDefectsPath = Paths.get(sampleDataFolderPath.toString(), "RR1_With_Artifacts.ibi");
Path cleanedDataPath = Paths.get(sampleDataFolderPath.toString(), "RR1_Cleaned.ibi");
| dataWithDefects = reader.readIBIFile(dataWithDefectsPath.toString(), TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/HFCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
public class HFCalculator implements HRVPowerSpectrumProcessor {
private static final double HF_LOWER_BOUND = 0.15;
private static final double HF_UPPER_BOUND = 0.4;
@Override | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HFCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
public class HFCalculator implements HRVPowerSpectrumProcessor {
private static final double HF_LOWER_BOUND = 0.15;
private static final double HF_UPPER_BOUND = 0.4;
@Override | public HRVParameter process(PowerSpectrum ps) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/HFCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
public class HFCalculator implements HRVPowerSpectrumProcessor {
private static final double HF_LOWER_BOUND = 0.15;
private static final double HF_UPPER_BOUND = 0.4;
@Override
public HRVParameter process(PowerSpectrum ps) {
| // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HFCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
public class HFCalculator implements HRVPowerSpectrumProcessor {
private static final double HF_LOWER_BOUND = 0.15;
private static final double HF_UPPER_BOUND = 0.4;
@Override
public HRVParameter process(PowerSpectrum ps) {
| var calcLF = new PowerSpectrumIntegralCalculator(HF_LOWER_BOUND, HF_UPPER_BOUND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/SDNNCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; | package hrv.lib.hrv.calc.parameter;
public class SDNNCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/SDNNCalculator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
package hrv.lib.hrv.calc.parameter;
public class SDNNCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculator.java
// public class AvgSampleSizeCalculator implements HRVDataProcessor {
//
// @Override
// public HRVParameter process(RRData data) {
// double maxX = data.getTimeAxis()[data.getTimeAxis().length - 1];
// double minX = data.getTimeAxis()[0];
// double xLength = maxX - minX;
// return new HRVParameter(HRVParameterEnum.AVG_SAMPLE_SIZE, xLength / (data.getTimeAxis().length - 1),
// "1 / " + data.getTimeAxisUnit().toString());
// }
//
//
// @Override
// public boolean validData(RRData data) {
// return data.getValueAxis().length > 0;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.AvgSampleSizeCalculator;
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.transform.DftNormalization;
import org.apache.commons.math3.transform.FastFourierTransformer;
import org.apache.commons.math3.transform.TransformType; | package hrv.lib.hrv.calc.psd;
/**
* Uses FFT to estimate the power spectra density of RR-Data-Intervals
*
* @author Julian
*
*/
public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
/**
* Calculates the power spectrum density (PSD) of the given
* rr-interval-data. The sampling rate is used to sample the interpolated
* rr-interval-data.
*
* @param rr
* rr-interval-data in seconds
* @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
*/
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculator.java
// public class AvgSampleSizeCalculator implements HRVDataProcessor {
//
// @Override
// public HRVParameter process(RRData data) {
// double maxX = data.getTimeAxis()[data.getTimeAxis().length - 1];
// double minX = data.getTimeAxis()[0];
// double xLength = maxX - minX;
// return new HRVParameter(HRVParameterEnum.AVG_SAMPLE_SIZE, xLength / (data.getTimeAxis().length - 1),
// "1 / " + data.getTimeAxisUnit().toString());
// }
//
//
// @Override
// public boolean validData(RRData data) {
// return data.getValueAxis().length > 0;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.AvgSampleSizeCalculator;
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.transform.DftNormalization;
import org.apache.commons.math3.transform.FastFourierTransformer;
import org.apache.commons.math3.transform.TransformType;
package hrv.lib.hrv.calc.psd;
/**
* Uses FFT to estimate the power spectra density of RR-Data-Intervals
*
* @author Julian
*
*/
public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
/**
* Calculates the power spectrum density (PSD) of the given
* rr-interval-data. The sampling rate is used to sample the interpolated
* rr-interval-data.
*
* @param rr
* rr-interval-data in seconds
* @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
*/
@Override | public PowerSpectrum calculateEstimate(RRData rr) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculator.java
// public class AvgSampleSizeCalculator implements HRVDataProcessor {
//
// @Override
// public HRVParameter process(RRData data) {
// double maxX = data.getTimeAxis()[data.getTimeAxis().length - 1];
// double minX = data.getTimeAxis()[0];
// double xLength = maxX - minX;
// return new HRVParameter(HRVParameterEnum.AVG_SAMPLE_SIZE, xLength / (data.getTimeAxis().length - 1),
// "1 / " + data.getTimeAxisUnit().toString());
// }
//
//
// @Override
// public boolean validData(RRData data) {
// return data.getValueAxis().length > 0;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.AvgSampleSizeCalculator;
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.transform.DftNormalization;
import org.apache.commons.math3.transform.FastFourierTransformer;
import org.apache.commons.math3.transform.TransformType; | package hrv.lib.hrv.calc.psd;
/**
* Uses FFT to estimate the power spectra density of RR-Data-Intervals
*
* @author Julian
*
*/
public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
/**
* Calculates the power spectrum density (PSD) of the given
* rr-interval-data. The sampling rate is used to sample the interpolated
* rr-interval-data.
*
* @param rr
* rr-interval-data in seconds
* @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
*/
@Override
public PowerSpectrum calculateEstimate(RRData rr) {
double[] power = calculatePower(rr);
double[] frequencies = calculateFrequencies(rr);
return new PowerSpectrum(power, frequencies);
}
private double[] calculatePower(RRData rr) {
double[] rrY = rr.getValueAxis(); | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculator.java
// public class AvgSampleSizeCalculator implements HRVDataProcessor {
//
// @Override
// public HRVParameter process(RRData data) {
// double maxX = data.getTimeAxis()[data.getTimeAxis().length - 1];
// double minX = data.getTimeAxis()[0];
// double xLength = maxX - minX;
// return new HRVParameter(HRVParameterEnum.AVG_SAMPLE_SIZE, xLength / (data.getTimeAxis().length - 1),
// "1 / " + data.getTimeAxisUnit().toString());
// }
//
//
// @Override
// public boolean validData(RRData data) {
// return data.getValueAxis().length > 0;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.AvgSampleSizeCalculator;
import org.apache.commons.math3.complex.Complex;
import org.apache.commons.math3.transform.DftNormalization;
import org.apache.commons.math3.transform.FastFourierTransformer;
import org.apache.commons.math3.transform.TransformType;
package hrv.lib.hrv.calc.psd;
/**
* Uses FFT to estimate the power spectra density of RR-Data-Intervals
*
* @author Julian
*
*/
public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
/**
* Calculates the power spectrum density (PSD) of the given
* rr-interval-data. The sampling rate is used to sample the interpolated
* rr-interval-data.
*
* @param rr
* rr-interval-data in seconds
* @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
*/
@Override
public PowerSpectrum calculateEstimate(RRData rr) {
double[] power = calculatePower(rr);
double[] frequencies = calculateFrequencies(rr);
return new PowerSpectrum(power, frequencies);
}
private double[] calculatePower(RRData rr) {
double[] rrY = rr.getValueAxis(); | var calc = new AvgSampleSizeCalculator(); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectralDensityEstimator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.psd;
@FunctionalInterface
public interface PowerSpectralDensityEstimator {
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectralDensityEstimator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.psd;
@FunctionalInterface
public interface PowerSpectralDensityEstimator {
| PowerSpectrum calculateEstimate(RRData rr); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/MeanCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.Mean; | package hrv.lib.hrv.calc.parameter;
public class MeanCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/MeanCalculator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
package hrv.lib.hrv.calc.parameter;
public class MeanCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/ModeCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class ModeCalculatorTest {
@Test
void testModeCalc() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/ModeCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class ModeCalculatorTest {
@Test
void testModeCalc() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/ModeCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class ModeCalculatorTest {
@Test
void testModeCalc() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/ModeCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class ModeCalculatorTest {
@Test
void testModeCalc() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutDataManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVCutDataManipulatorTest {
@Test
void cutTest() { | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutDataManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVCutDataManipulatorTest {
@Test
void cutTest() { | RRData data = RRData.createFromRRInterval(new double[] { 1.0, 1.1, 1.2, 0.9, 1.0 }, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutDataManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVCutDataManipulatorTest {
@Test
void cutTest() { | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVCutDataManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVCutDataManipulatorTest {
@Test
void cutTest() { | RRData data = RRData.createFromRRInterval(new double[] { 1.0, 1.1, 1.2, 0.9, 1.0 }, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/continous/HRVContinuousHeartRate.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum; | package hrv.lib.hrv.calc.continous;
public class HRVContinuousHeartRate extends HRVContinuousParameterCalculator {
public HRVContinuousHeartRate(int size) {
super(size);
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/continous/HRVContinuousHeartRate.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
package hrv.lib.hrv.calc.continous;
public class HRVContinuousHeartRate extends HRVContinuousParameterCalculator {
public HRVContinuousHeartRate(int size) {
super(size);
}
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/continous/HRVContinuousHeartRate.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum; | package hrv.lib.hrv.calc.continous;
public class HRVContinuousHeartRate extends HRVContinuousParameterCalculator {
public HRVContinuousHeartRate(int size) {
super(size);
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/continous/HRVContinuousHeartRate.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
package hrv.lib.hrv.calc.continous;
public class HRVContinuousHeartRate extends HRVContinuousParameterCalculator {
public HRVContinuousHeartRate(int size) {
super(size);
}
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/continous/HRVContinuousHeartRate.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum; | package hrv.lib.hrv.calc.continous;
public class HRVContinuousHeartRate extends HRVContinuousParameterCalculator {
public HRVContinuousHeartRate(int size) {
super(size);
}
@Override
public HRVParameter process(RRData data) {
double[] values = data.getValueAxis();
var sum = 0.0;
for (double value : values) {
sum += 1.0 / value;
}
double beatsPerSecond = sum / values.length;
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/continous/HRVContinuousHeartRate.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
package hrv.lib.hrv.calc.continous;
public class HRVContinuousHeartRate extends HRVContinuousParameterCalculator {
public HRVContinuousHeartRate(int size) {
super(size);
}
@Override
public HRVParameter process(RRData data) {
double[] values = data.getValueAxis();
var sum = 0.0;
for (double value : values) {
sum += 1.0 / value;
}
double beatsPerSecond = sum / values.length;
| return new HRVParameter(HRVParameterEnum.HEART_RATE, beatsPerSecond * 60, "Beats / Minute"); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVSubtractMeanManipulator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.Mean; | package hrv.lib.hrv.calc.manipulator;
public class HRVSubtractMeanManipulator implements HRVDataManipulator {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVSubtractMeanManipulator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
package hrv.lib.hrv.calc.manipulator;
public class HRVSubtractMeanManipulator implements HRVDataManipulator {
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/VLFCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
public class VLFCalculator implements HRVPowerSpectrumProcessor {
private static final double VLF_LOWER_BOUND = 0.00;
private static final double VLF_UPPER_BOUND = 0.04;
@Override | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/VLFCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
public class VLFCalculator implements HRVPowerSpectrumProcessor {
private static final double VLF_LOWER_BOUND = 0.00;
private static final double VLF_UPPER_BOUND = 0.04;
@Override | public HRVParameter process(PowerSpectrum ps) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/VLFCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator; | package hrv.lib.hrv.calc.parameter;
public class VLFCalculator implements HRVPowerSpectrumProcessor {
private static final double VLF_LOWER_BOUND = 0.00;
private static final double VLF_UPPER_BOUND = 0.04;
@Override
public HRVParameter process(PowerSpectrum ps) { | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrumIntegralCalculator.java
// public class PowerSpectrumIntegralCalculator implements HRVPowerSpectrumProcessor {
//
// private final double lowerIntegrationLimit;
// private final double upperIntegrationLimit;
//
// public PowerSpectrumIntegralCalculator(double lowerIntegrationLimit, double upperIntegrationLimit) {
// this.lowerIntegrationLimit = lowerIntegrationLimit;
// this.upperIntegrationLimit = upperIntegrationLimit;
// }
//
// @Override
// public HRVParameter process(PowerSpectrum ps) {
// var psAdapter = new PowerSpectrumUnivariateFunctionAdapter(ps);
// var integrator = new TrapezoidIntegrator();
// return new HRVParameter(HRVParameterEnum.NON,
// integrator.integrate(BaseAbstractUnivariateIntegrator.DEFAULT_MAX_ITERATIONS_COUNT,
// psAdapter,
// lowerIntegrationLimit,
// upperIntegrationLimit),
// ps.getUnit() + "*" + ps.getUnit());
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/VLFCalculator.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.PowerSpectrumIntegralCalculator;
package hrv.lib.hrv.calc.parameter;
public class VLFCalculator implements HRVPowerSpectrumProcessor {
private static final double VLF_LOWER_BOUND = 0.00;
private static final double VLF_UPPER_BOUND = 0.04;
@Override
public HRVParameter process(PowerSpectrum ps) { | var calcVLF = new PowerSpectrumIntegralCalculator(VLF_LOWER_BOUND, VLF_UPPER_BOUND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/SD2Calculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; | package hrv.lib.hrv.calc.parameter;
public class SD2Calculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/SD2Calculator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
package hrv.lib.hrv.calc.parameter;
public class SD2Calculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSplineInterpolatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; | package hrv.lib.hrv.calc.manipulator;
class HRVSplineInterpolatorTest {
@Test
void testTooShortData() {
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSplineInterpolatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
package hrv.lib.hrv.calc.manipulator;
class HRVSplineInterpolatorTest {
@Test
void testTooShortData() {
| RRData data = RRData.createFromRRInterval(new double[]{1.0, 0.9}, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSplineInterpolatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; | package hrv.lib.hrv.calc.manipulator;
class HRVSplineInterpolatorTest {
@Test
void testTooShortData() {
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSplineInterpolatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
package hrv.lib.hrv.calc.manipulator;
class HRVSplineInterpolatorTest {
@Test
void testTooShortData() {
| RRData data = RRData.createFromRRInterval(new double[]{1.0, 0.9}, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/window/HammingWindow.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVDataManipulator.java
// @FunctionalInterface
// public interface HRVDataManipulator {
//
// /**
// * Manipulates the given data and returns the manipulated data. The given data must at least contain three data-points.
// * @param data data to manipulate.
// * @return Manipulated data.
// */
// RRData manipulate(RRData data);
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.manipulator.HRVDataManipulator; | package hrv.lib.hrv.calc.manipulator.window;
public class HammingWindow implements HRVDataManipulator {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVDataManipulator.java
// @FunctionalInterface
// public interface HRVDataManipulator {
//
// /**
// * Manipulates the given data and returns the manipulated data. The given data must at least contain three data-points.
// * @param data data to manipulate.
// * @return Manipulated data.
// */
// RRData manipulate(RRData data);
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/window/HammingWindow.java
import hrv.lib.hrv.RRData;
import hrv.lib.hrv.calc.manipulator.HRVDataManipulator;
package hrv.lib.hrv.calc.manipulator.window;
public class HammingWindow implements HRVDataManipulator {
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java | // Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.units.TimeUnit; | package hrv.lib.hrv.calc.psd;
public class PowerSpectrum {
private double[] power;
private double[] frequency; | // Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
import hrv.lib.units.TimeUnit;
package hrv.lib.hrv.calc.psd;
public class PowerSpectrum {
private double[] power;
private double[] frequency; | private TimeUnit unit; |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/SDSDCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class SDSDCalculatorTest {
@Test
void testForZeroCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/SDSDCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class SDSDCalculatorTest {
@Test
void testForZeroCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/SDSDCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class SDSDCalculatorTest {
@Test
void testForZeroCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/SDSDCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class SDSDCalculatorTest {
@Test
void testForZeroCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/HRVLibFacadeTest.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import java.util.EnumSet;
import java.util.List;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv;
class HRVLibFacadeTest {
@Test
void testDefaultParamCalculation() { | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/HRVLibFacadeTest.java
import java.util.EnumSet;
import java.util.List;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv;
class HRVLibFacadeTest {
@Test
void testDefaultParamCalculation() { | RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/HRVLibFacadeTest.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import java.util.EnumSet;
import java.util.List;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv;
class HRVLibFacadeTest {
@Test
void testDefaultParamCalculation() {
RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND);
HRVLibFacade facade = new HRVLibFacade(data); | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/HRVLibFacadeTest.java
import java.util.EnumSet;
import java.util.List;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv;
class HRVLibFacadeTest {
@Test
void testDefaultParamCalculation() {
RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND);
HRVLibFacade facade = new HRVLibFacade(data); | List<HRVParameter> result = facade.calculateParameters(); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/HRVLibFacadeTest.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import java.util.EnumSet;
import java.util.List;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv;
class HRVLibFacadeTest {
@Test
void testDefaultParamCalculation() {
RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND);
HRVLibFacade facade = new HRVLibFacade(data);
List<HRVParameter> result = facade.calculateParameters();
assertEquals(12, result.size());
}
@Test
void testParamCalculation() {
RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND);
HRVLibFacade facade = new HRVLibFacade(data); | // Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameter.java
// public class HRVParameter {
//
// private HRVParameterEnum type;
// private String unit;
// private double value;
//
// /**
// * Creates a new HRV-Parameter
// */
// public HRVParameter() {
// // Just empty constructor
// }
//
// /**
// * Creates a new HRV-Parameter
// * @param value Value of the parameter
// * @param unit Unit of the parameter
// */
// public HRVParameter(HRVParameterEnum type, double value, String unit) {
// this.type = type;
// this.value = value;
// this.setUnit(unit);
// }
//
// public String getName() {
// return type.toString();
// }
//
// public HRVParameterEnum getType() {
// return type;
// }
//
// public double getValue() {
// return value;
// }
//
// public void setValue(double value) {
// this.value = value;
// }
//
// public String getUnit() {
// return unit;
// }
//
// public void setUnit(String unit) {
// this.unit = unit;
// }
//
// /**
// * Returns a string with the following format:
// * <Name>: <Value> <Unit>
// */
// @Override
// public String toString() {
// return type.toString() + ": " + value + " " + unit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVParameterEnum.java
// public enum HRVParameterEnum {
// NON, AMPLITUDEMODE, AVG_SAMPLE_SIZE, BAEVSKY, HEART_RATE, HFNU, LFNU, LFHF, LF, HF, VLF, MEAN, MODE, MXDMN, NN50, PNN50, RMSSD, SDNN, SD1, SD2, SD1SD2, SDSD
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/HRVLibFacadeTest.java
import java.util.EnumSet;
import java.util.List;
import hrv.lib.hrv.calc.parameter.HRVParameter;
import hrv.lib.hrv.calc.parameter.HRVParameterEnum;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv;
class HRVLibFacadeTest {
@Test
void testDefaultParamCalculation() {
RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND);
HRVLibFacade facade = new HRVLibFacade(data);
List<HRVParameter> result = facade.calculateParameters();
assertEquals(12, result.size());
}
@Test
void testParamCalculation() {
RRData data = RRData.createFromRRInterval(new double[] {1,1,1,1,1,1,1,1}, TimeUnit.SECOND);
HRVLibFacade facade = new HRVLibFacade(data); | facade.setParameters(EnumSet.of(HRVParameterEnum.HF)); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/NN50CalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class NN50CalculatorTest {
@Test
void testCalculationSeconds() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/NN50CalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class NN50CalculatorTest {
@Test
void testCalculationSeconds() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/NN50CalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class NN50CalculatorTest {
@Test
void testCalculationSeconds() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/NN50CalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class NN50CalculatorTest {
@Test
void testCalculationSeconds() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class AvgSampleSizeCalculatorTest {
@Test
void testSampleSizeCalculation() {
double[] timeData1 = new double[] { 1.0, 2.0, 3.0, 4.0 };
double[] timeData2 = new double[] { 0.0, 2.0, 2.5, 4.0 };
double[] timeData3 = new double[] { 1.0, 2.5, 3.5, 20.0 };
AvgSampleSizeCalculator calc = new AvgSampleSizeCalculator();
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class AvgSampleSizeCalculatorTest {
@Test
void testSampleSizeCalculation() {
double[] timeData1 = new double[] { 1.0, 2.0, 3.0, 4.0 };
double[] timeData2 = new double[] { 0.0, 2.0, 2.5, 4.0 };
double[] timeData3 = new double[] { 1.0, 2.5, 3.5, 20.0 };
AvgSampleSizeCalculator calc = new AvgSampleSizeCalculator();
| RRData data1 = new RRData(timeData1, TimeUnit.SECOND, null, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class AvgSampleSizeCalculatorTest {
@Test
void testSampleSizeCalculation() {
double[] timeData1 = new double[] { 1.0, 2.0, 3.0, 4.0 };
double[] timeData2 = new double[] { 0.0, 2.0, 2.5, 4.0 };
double[] timeData3 = new double[] { 1.0, 2.5, 3.5, 20.0 };
AvgSampleSizeCalculator calc = new AvgSampleSizeCalculator();
| // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class AvgSampleSizeCalculatorTest {
@Test
void testSampleSizeCalculation() {
double[] timeData1 = new double[] { 1.0, 2.0, 3.0, 4.0 };
double[] timeData2 = new double[] { 0.0, 2.0, 2.5, 4.0 };
double[] timeData3 = new double[] { 1.0, 2.5, 3.5, 20.0 };
AvgSampleSizeCalculator calc = new AvgSampleSizeCalculator();
| RRData data1 = new RRData(timeData1, TimeUnit.SECOND, null, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.parameter;
public class AvgSampleSizeCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/AvgSampleSizeCalculator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.parameter;
public class AvgSampleSizeCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/AmplitudeModeCalculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData; | package hrv.lib.hrv.calc.parameter;
public class AmplitudeModeCalculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/AmplitudeModeCalculator.java
import hrv.lib.hrv.RRData;
package hrv.lib.hrv.calc.parameter;
public class AmplitudeModeCalculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/BaevskyCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class BaevskyCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/BaevskyCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class BaevskyCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/BaevskyCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class BaevskyCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/BaevskyCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class BaevskyCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSubtractMeanManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVSubtractMeanManipulatorTest {
@Test
void testSub() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 0.0, 1.0, 2.0, 4.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSubtractMeanManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVSubtractMeanManipulatorTest {
@Test
void testSub() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 0.0, 1.0, 2.0, 4.0 }; | RRData data = new RRData(time1, TimeUnit.SECOND, values1, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSubtractMeanManipulatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.manipulator;
class HRVSubtractMeanManipulatorTest {
@Test
void testSub() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 0.0, 1.0, 2.0, 4.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/manipulator/HRVSubtractMeanManipulatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.manipulator;
class HRVSubtractMeanManipulatorTest {
@Test
void testSub() {
double[] time1 = new double[] { 0.0, 1.0, 2.0, 4.0 };
double[] values1 = new double[] { 0.0, 1.0, 2.0, 4.0 }; | RRData data = new RRData(time1, TimeUnit.SECOND, values1, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/AmplitudeModeCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class AmplitudeModeCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/AmplitudeModeCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class AmplitudeModeCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/test/java/hrv/lib/hrv/calc/parameter/AmplitudeModeCalculatorTest.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
| import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; | package hrv.lib.hrv.calc.parameter;
class AmplitudeModeCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
//
// Path: lib/src/main/java/hrv/lib/units/TimeUnit.java
// public enum TimeUnit {
// DAY("d"),
// HOUR("h"),
// MINUTE("m"),
// SECOND("s"),
// MILLISECOND("ms");
//
// private final String asText;
//
// TimeUnit(String asText) {
// this.asText = asText;
// }
//
// @Override
// public String toString() {
// return asText;
// }
// }
// Path: lib/src/test/java/hrv/lib/hrv/calc/parameter/AmplitudeModeCalculatorTest.java
import hrv.lib.hrv.RRData;
import hrv.lib.units.TimeUnit;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
package hrv.lib.hrv.calc.parameter;
class AmplitudeModeCalculatorTest {
@Test
void testCalculation() {
double[] valueData = new double[] { 0.0, 1.0, 2.0, 3.0, 4.0, 4.1, 5.0, 5.01, 5.02, 6.0, 7.0 }; | RRData data = new RRData(null, TimeUnit.SECOND, valueData, TimeUnit.SECOND); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVSplineInterpolator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.analysis.interpolation.SplineInterpolator;
import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction; | package hrv.lib.hrv.calc.manipulator;
/**
* Interpolates given RR-Data with a given sampling-rate. The given data must at least contain 3 data-points.
* @author Julian
*
*/
public class HRVSplineInterpolator implements HRVDataManipulator {
private final double samplingRate;
public HRVSplineInterpolator(double samplingRate) {
this.samplingRate = samplingRate;
}
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/manipulator/HRVSplineInterpolator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.analysis.interpolation.SplineInterpolator;
import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
package hrv.lib.hrv.calc.manipulator;
/**
* Interpolates given RR-Data with a given sampling-rate. The given data must at least contain 3 data-points.
* @author Julian
*
*/
public class HRVSplineInterpolator implements HRVDataManipulator {
private final double samplingRate;
public HRVSplineInterpolator(double samplingRate) {
this.samplingRate = samplingRate;
}
@Override | public RRData manipulate(RRData data) { |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVPowerSpectrumProcessor.java | // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
| import hrv.lib.hrv.calc.psd.PowerSpectrum; | package hrv.lib.hrv.calc.parameter;
@FunctionalInterface
public interface HRVPowerSpectrumProcessor {
| // Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
//
// private double[] power;
// private double[] frequency;
// private TimeUnit unit;
//
// public PowerSpectrum(double[] power, double[] frequency) {
// this.power = power;
// this.frequency = frequency;
// }
//
// public double[] getPower() {
// return power;
// }
//
// public void setPower(double[] power) {
// this.power = power;
// }
//
// public double[] getFrequency() {
// return frequency;
// }
//
// public void setFrequency(double[] frequency) {
// this.frequency = frequency;
// }
//
// public TimeUnit getUnit() {
// return unit;
// }
//
// public void setIncomingUnit(TimeUnit unit) {
// this.unit = unit;
// }
//
// /**
// * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
// * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
// * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
// * the same values and that they increase with the same rate.
// *
// * @param ps {@code PowerSpectrum} to add.
// */
// public void add(PowerSpectrum ps) {
// //Use the shorter length to avoid array out of bounds.
// int shorterLength = Math.min(ps.getPower().length, this.power.length);
//
// for (var i = 0; i < shorterLength; i++) {
// this.power[i] += ps.getPower()[i];
// }
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/HRVPowerSpectrumProcessor.java
import hrv.lib.hrv.calc.psd.PowerSpectrum;
package hrv.lib.hrv.calc.parameter;
@FunctionalInterface
public interface HRVPowerSpectrumProcessor {
| HRVParameter process(PowerSpectrum ps); |
HRVBand/hrv-lib | lib/src/main/java/hrv/lib/hrv/calc/parameter/SD1Calculator.java | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
| import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; | package hrv.lib.hrv.calc.parameter;
public class SD1Calculator implements HRVDataProcessor {
@Override | // Path: lib/src/main/java/hrv/lib/hrv/RRData.java
// public class RRData {
//
// private final TimeUnit rrValueAxisUnit;
// private final /*@ spec_public */ TimeUnit rrTimeAxisUnit;
//
// private final double[] rrValuesAxis;
// private final double[] rrTimeAxis;
//
// public RRData(double[] timeAxis, TimeUnit timeAxisUnit, double[] valueAxis, TimeUnit valueAxisUnit) {
// this.rrValuesAxis = valueAxis;
// this.rrValueAxisUnit = valueAxisUnit;
//
// this.rrTimeAxis = timeAxis;
// this.rrTimeAxisUnit = timeAxisUnit;
// }
//
// /**
// * Creates a new RRData object from an RR-Interval
// *
// * @param rrInterval
// * RR-Interval
// * @param unit
// * of the given RR-Data.
// * @return new RRData object with given RR-Interval data.
// */
// public static RRData createFromRRInterval(double[] rrInterval, TimeUnit unit) {
// var rrTimeAxis = new double[rrInterval.length];
// for (var i = 1; i < rrInterval.length; i++) {
// rrTimeAxis[i] = rrTimeAxis[i - 1] + rrInterval[i - 1];
// }
//
// return new RRData(rrTimeAxis, unit, rrInterval, unit);
// }
//
// public double[] getValueAxis() {
// return rrValuesAxis;
// }
//
// public double[] getTimeAxis() {
// return rrTimeAxis;
// }
//
// public TimeUnit getValueAxisUnit() {
// return rrValueAxisUnit;
// }
//
// public TimeUnit getTimeAxisUnit() {
// return rrTimeAxisUnit;
// }
// }
// Path: lib/src/main/java/hrv/lib/hrv/calc/parameter/SD1Calculator.java
import hrv.lib.hrv.RRData;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
package hrv.lib.hrv.calc.parameter;
public class SD1Calculator implements HRVDataProcessor {
@Override | public HRVParameter process(RRData data) { |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Consumers.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
// @Reconsume(5)
// public class TestConsumer {
// @Reconsume(3)
// public Action dishAdd(Dish dish){
// //do some thine
// return Action.commit;
// }
//
//
// public Action dishDel(Long dishId, Message message){
// //Message 为阿里云mq 原生消息体
//
// //do some thing
// return Action.commit;
// }
//
// public Action jackjson(@JackJson Dish dish){
// //do some thine
// return Action.commit;
// }
// }
| import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import com.mq.aliyun.example.consumers.TestConsumer; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
public class Consumers implements ConsumerAble {
@Override | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
// @Reconsume(5)
// public class TestConsumer {
// @Reconsume(3)
// public Action dishAdd(Dish dish){
// //do some thine
// return Action.commit;
// }
//
//
// public Action dishDel(Long dishId, Message message){
// //Message 为阿里云mq 原生消息体
//
// //do some thing
// return Action.commit;
// }
//
// public Action jackjson(@JackJson Dish dish){
// //do some thine
// return Action.commit;
// }
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Consumers.java
import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import com.mq.aliyun.example.consumers.TestConsumer;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
public class Consumers implements ConsumerAble {
@Override | public void init(Ons ons) { |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Consumers.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
// @Reconsume(5)
// public class TestConsumer {
// @Reconsume(3)
// public Action dishAdd(Dish dish){
// //do some thine
// return Action.commit;
// }
//
//
// public Action dishDel(Long dishId, Message message){
// //Message 为阿里云mq 原生消息体
//
// //do some thing
// return Action.commit;
// }
//
// public Action jackjson(@JackJson Dish dish){
// //do some thine
// return Action.commit;
// }
// }
| import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import com.mq.aliyun.example.consumers.TestConsumer; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
public class Consumers implements ConsumerAble {
@Override
public void init(Ons ons) {
//订阅普通消息(无序)
ons.consumer("CID_MEICANYUN_ORDER")
.subscribeTopic("MEICANYUN") | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
// @Reconsume(5)
// public class TestConsumer {
// @Reconsume(3)
// public Action dishAdd(Dish dish){
// //do some thine
// return Action.commit;
// }
//
//
// public Action dishDel(Long dishId, Message message){
// //Message 为阿里云mq 原生消息体
//
// //do some thing
// return Action.commit;
// }
//
// public Action jackjson(@JackJson Dish dish){
// //do some thine
// return Action.commit;
// }
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Consumers.java
import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import com.mq.aliyun.example.consumers.TestConsumer;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
public class Consumers implements ConsumerAble {
@Override
public void init(Ons ons) {
//订阅普通消息(无序)
ons.consumer("CID_MEICANYUN_ORDER")
.subscribeTopic("MEICANYUN") | .subscribeTag("dish.add || dish.update",TestConsumer::dishAdd) |
onepiecex/mq-aliyun | mq-aliyun-example/src/main/java/com/mq/aliyun/example/Consumers.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
// @Reconsume(5)
// public class TestConsumer {
// @Reconsume(3)
// public Action dishAdd(Dish dish){
// //do some thine
// return Action.commit;
// }
//
//
// public Action dishDel(Long dishId, Message message){
// //Message 为阿里云mq 原生消息体
//
// //do some thing
// return Action.commit;
// }
//
// public Action jackjson(@JackJson Dish dish){
// //do some thine
// return Action.commit;
// }
// }
| import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import com.mq.aliyun.example.consumers.TestConsumer; | package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
public class Consumers implements ConsumerAble {
@Override
public void init(Ons ons) {
//订阅普通消息(无序)
ons.consumer("CID_MEICANYUN_ORDER")
.subscribeTopic("MEICANYUN")
.subscribeTag("dish.add || dish.update",TestConsumer::dishAdd)
.subscribeTag("dish.del",TestConsumer::dishDel);
//订阅顺序消息 | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/ConsumerAble.java
// public interface ConsumerAble {
// String BROADCASTING = "BROADCASTING";
// String CLUSTERING = "CLUSTERING";
//
// void init(Ons ons);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/Ons.java
// public interface Ons {
// void defaultTopic(String topic);
// ConsumerBuild consumer(String cid);
// ConsumerBuild consumer(String cid, ConsumerOptional consumerOptional);
//
// ConsumerBuild consumerOrdered(String cid);
// ConsumerBuild consumerOrdered(String cid, ConsumerOptional consumerOptional);
// }
//
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/ConsumerOptional.java
// public class ConsumerOptional {
// //消费线程数
// private Integer consumeThread;
// //消费模式(集群 : CLUSTERING, 广播 : BROADCASTING)
// private String consumerModel;
// //消息消费失败时的最大重试次数
// private Integer maxReconsume;
// //顺序消息消费失败进行重试前的等待时间 单位(毫秒)
// private Integer suspendTime;
//
// public ConsumerOptional(){}
//
// public ConsumerOptional(Integer consumeThread){
// this.consumeThread = consumeThread;
// }
//
// public ConsumerOptional(Integer consumeThread,Integer maxReconsume){
// this.consumeThread = consumeThread;
// this.maxReconsume = maxReconsume;
// }
//
// public Integer getConsumeThread() {
// return consumeThread;
// }
//
// public ConsumerOptional setConsumeThread(Integer consumeThread) {
// this.consumeThread = consumeThread;
// return this;
// }
//
// public String getConsumerModel() {
// return consumerModel;
// }
//
// public ConsumerOptional setConsumerModel(String consumerModel) {
// this.consumerModel = consumerModel;
// return this;
// }
//
// public Integer getMaxReconsume() {
// return maxReconsume;
// }
//
// public ConsumerOptional setMaxReconsume(Integer maxReconsume) {
// this.maxReconsume = maxReconsume;
// return this;
// }
//
// public Integer getSuspendTime() {
// return suspendTime;
// }
//
// public ConsumerOptional setSuspendTime(Integer suspendTime) {
// this.suspendTime = suspendTime;
// return this;
// }
// }
//
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/consumers/TestConsumer.java
// @Reconsume(5)
// public class TestConsumer {
// @Reconsume(3)
// public Action dishAdd(Dish dish){
// //do some thine
// return Action.commit;
// }
//
//
// public Action dishDel(Long dishId, Message message){
// //Message 为阿里云mq 原生消息体
//
// //do some thing
// return Action.commit;
// }
//
// public Action jackjson(@JackJson Dish dish){
// //do some thine
// return Action.commit;
// }
// }
// Path: mq-aliyun-example/src/main/java/com/mq/aliyun/example/Consumers.java
import com.github.mq.consumer.ConsumerAble;
import com.github.mq.consumer.Ons;
import com.github.mq.consumer.models.ConsumerOptional;
import com.mq.aliyun.example.consumers.TestConsumer;
package com.mq.aliyun.example;
/**
* Created by wangziqing on 17/7/25.
*/
public class Consumers implements ConsumerAble {
@Override
public void init(Ons ons) {
//订阅普通消息(无序)
ons.consumer("CID_MEICANYUN_ORDER")
.subscribeTopic("MEICANYUN")
.subscribeTag("dish.add || dish.update",TestConsumer::dishAdd)
.subscribeTag("dish.del",TestConsumer::dishDel);
//订阅顺序消息 | ons.consumerOrdered("CID_ORDER_TEST_DISH",new ConsumerOptional().setConsumeThread(10)) |
onepiecex/mq-aliyun | mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractorWrapper.java | // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
| import com.aliyun.openservices.ons.api.Message;
import com.github.mq.consumer.models.Result;
import java.lang.annotation.Annotation; | package com.github.mq.consumer.parms;
/**
* Created by wangziqing on 17/7/26.
*/
public class ArgumentExtractorWrapper {
private ArgumentExtractor<?> argumentExtractor;
private Annotation annotation;
private Class<?> parameterClass;
| // Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/models/Result.java
// public class Result<T> {
// private T result;
// private Action action;
//
// public Result(T result) {
// this.result = result;
// }
//
// public Result(Action action) {
// this.action = action;
// }
//
// public Object getResult() {
// return result;
// }
//
// public Action getAction() {
// return action;
// }
// }
// Path: mq-aliyun-consumer-spring-boot-starter/src/main/java/com/github/mq/consumer/parms/ArgumentExtractorWrapper.java
import com.aliyun.openservices.ons.api.Message;
import com.github.mq.consumer.models.Result;
import java.lang.annotation.Annotation;
package com.github.mq.consumer.parms;
/**
* Created by wangziqing on 17/7/26.
*/
public class ArgumentExtractorWrapper {
private ArgumentExtractor<?> argumentExtractor;
private Annotation annotation;
private Class<?> parameterClass;
| public Result excuteExtract(Message message){ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.