Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when specifying only one temporal window in temporalCovariateSettings #200

Closed
gowthamrao opened this issue May 31, 2023 · 4 comments · Fixed by #234
Closed

Error when specifying only one temporal window in temporalCovariateSettings #200

gowthamrao opened this issue May 31, 2023 · 4 comments · Fixed by #234
Assignees
Labels
Milestone

Comments

@gowthamrao
Copy link
Member

I get the following error when specifying only one window in temporal covariate settings object

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
org.json.JSONException: JSONObject["temporalEndDays"] is not a JSONArray.

reproducible code


cohortDefinitionSet <-
  CohortGenerator::getCohortDefinitionSet(
    settingsFileName = "settings/CohortsToCreate.csv",
    jsonFolder = "cohorts",
    sqlFolder = "sql/sql_server",
    packageName = "SkeletonCohortDiagnosticsStudy",
    cohortFileNameValue = "cohortId"
  )

connectionDetails <- Eunomia::getEunomiaConnectionDetails()
connection <-
  DatabaseConnector::connect(connectionDetails = connectionDetails)


cohortTableNames = CohortGenerator::getCohortTableNames(cohortTable = 'cohort')

# Execution ----
## Create cohort tables on remote ----
CohortGenerator::createCohortTables(
  connectionDetails = connectionDetails,
  cohortDatabaseSchema = 'main',
  cohortTableNames = cohortTableNames,
  incremental = FALSE
)
## Generate cohort on remote ----
cohortGenerated <- CohortGenerator::generateCohortSet(
  connectionDetails = connectionDetails,
  cdmDatabaseSchema = 'main',
  cohortTableNames = cohortTableNames,
  cohortDefinitionSet = cohortDefinitionSet,
  cohortDatabaseSchema = 'main',
  incremental = FALSE
)

FeatureExtractionSettings <-
  FeatureExtraction::createTemporalCovariateSettings(
    useConditionEraGroupOverlap = TRUE,
    temporalStartDays = 0,
    temporalEndDays = 0
  )


featureExtractionOutput <-
  FeatureExtraction::getDbCovariateData(
    connection = connection,
    cdmDatabaseSchema = 'main',
    cohortDatabaseSchema = 'main',
    cohortTable = cohortTableNames$cohortTable,
    covariateSettings = FeatureExtractionCovariateSettings,
    aggregated = TRUE
  )

@gowthamrao
Copy link
Member Author

gowthamrao commented May 31, 2023

same error if


FeatureExtractionSettings <-
  FeatureExtraction::createTemporalCovariateSettings(
    useConditionEraGroupOverlap = TRUE,
    temporalStartDays = c(0),
    temporalEndDays = c(0)
  )

@ginberg
Copy link
Collaborator

ginberg commented May 31, 2023

hi @gowthamrao, can you share your sessionInfo()? I can't reproduce the error that you are getting

@ginberg
Copy link
Collaborator

ginberg commented Jun 5, 2023

Actually @gowthamrao I can reproduce the error now. I got another error since the "FeatureExtractionCovariateSettings" param in getDbCovariateData does not exist (it does work with FeatureExtractionSettings).

If you are specifying the start and end days as a list, it does work.

FeatureExtractionSettings <-
  FeatureExtraction::createTemporalCovariateSettings(
    useConditionEraGroupOverlap = TRUE,
    temporalStartDays = list(0),
    temporalEndDays = list(0)
  )

In the documentation it also states that these params should be a list, see
https://github.com/OHDSI/FeatureExtraction/blob/main/R/DefaultTemporalCovariateSettings.R#L114-L123
Does that work for you?

@anthonysena
Copy link
Collaborator

anthonysena commented Feb 2, 2024

In discussion with @ginberg we should add a type check for the temporalStartDays and temporalEndDays to ensure the data type is a list. It seems that when you specify c(0) it may not treat it as a proper vector and hence the error is raised.

@anthonysena anthonysena added this to the V3.5.0 milestone Feb 2, 2024
@anthonysena anthonysena added the bug label Feb 2, 2024
@ginberg ginberg self-assigned this Feb 16, 2024
ginberg added a commit that referenced this issue Feb 23, 2024
@ginberg ginberg linked a pull request Feb 27, 2024 that will close this issue
@ginberg ginberg closed this as completed Feb 27, 2024
@ginberg ginberg modified the milestones: V3.5.0, V3.4.1 Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants